private void Explorer_ViewSwitch()
 {
     try
     {
         //HACK: Disable drag and drop hook when in calendar mode
         //For some reason dragging an item in calendar view throws E_NOINTERFACE exception when DoDragDrop COM function is hooked (thread issue?)
         Outlook.View view = (Outlook.View)explorer.CurrentView;
         if (view.ViewType == Outlook.OlViewType.olCalendarView)
         {
             if (Hook.IsHooked)
             {
                 log.Info("Calendar view detected -- stopping hook");
                 StopHook();
             }
         }
         else
         {
             if (!Hook.IsHooked)
             {
                 log.Info("Non-calendar view detected -- starting hook");
                 StartHook();
             }
         }
     }
     catch (Exception ex)
     {
         log.Fatal("Fatal error", ex);
         StopHook();
     }
 }
Beispiel #2
0
        private void UpdateSelectedAppointmentsOrCreateNew(string tag)
        {
            Outlook.View view = Globals.ThisAddIn._Explorer.CurrentView as Outlook.View;
            if (view.ViewType != Outlook.OlViewType.olCalendarView)
            {
                return;
            }
            Outlook.Folder       folder  = Globals.ThisAddIn._Explorer.CurrentFolder as Outlook.Folder;
            Outlook.CalendarView calView = view as Outlook.CalendarView;

            if (Globals.ThisAddIn._Explorer.Selection.Count != 0)
            {
                foreach (object obj in Globals.ThisAddIn._Explorer.Selection)
                {
                    Outlook.AppointmentItem aitem = obj as Outlook.AppointmentItem;
                    if (aitem == null)
                    {
                        continue;
                    }

                    if (aitem.IsRecurring ||
                        aitem.MeetingStatus != Outlook.OlMeetingStatus.olNonMeeting)
                    {
                        // clone this appointment
                        DateTime dateStart = aitem.Start;
                        DateTime dateEnd   = aitem.End;
                        aitem             = folder.Items.Add("IPM.Appointment") as Outlook.AppointmentItem;
                        aitem.ReminderSet = false;
                        aitem.Start       = dateStart;
                        aitem.End         = dateEnd;
                    }

                    if (aitem.Subject == null)
                    {
                        aitem.Subject = tag;
                    }
                    else
                    {
                        aitem.Subject = tag + " " + aitem.Subject.Trim();
                    }
                    aitem.Save();
                }
            }
            else
            {
                DateTime dateStart            = calView.SelectedStartTime;
                DateTime dateEnd              = calView.SelectedEndTime;
                Outlook.AppointmentItem aitem = folder.Items.Add("IPM.Appointment") as Outlook.AppointmentItem;
                aitem.ReminderSet = false;
                aitem.Start       = dateStart;
                aitem.End         = dateEnd;
                aitem.Subject     = tag;
                aitem.Save();
            }
        }
Beispiel #3
0
        public NewJitsiAppointment()
        {
            // Get the Application object
            Outlook.Application application = Globals.ThisAddIn.Application;

            DateTime dateNull = new DateTime(4501, 1, 1, 0, 0, 0);

            Outlook.Explorer expl = application.ActiveExplorer();
            Outlook.View     view = expl.CurrentView as Outlook.View;

            try
            {
                // Generate meeting ID
                string jitsiRoomId = getRoomId();

                // Create meeting object
                newAppointment = (Outlook.AppointmentItem)application.CreateItem(Outlook.OlItemType.olAppointmentItem);


                // Appointment details
                newAppointment.MeetingStatus = Outlook.OlMeetingStatus.olMeeting;
                newAppointment.Location      = "Jitsi Meet";
                newAppointment.Body          = generateBody(jitsiRoomId);

                // Set appointment date if selected in calendar
                if (view.ViewType == Outlook.OlViewType.olCalendarView)
                {
                    Outlook.CalendarView calView   = view as Outlook.CalendarView;
                    DateTime             dateStart = calView.SelectedStartTime;
                    DateTime             dateEnd   = calView.SelectedEndTime;
                    if (dateStart != dateNull && dateEnd != dateNull)
                    {
                        newAppointment.Start = dateStart;
                        newAppointment.End   = dateEnd;
                    }
                }

                // Display ribbon group, then the appointment window
                Globals.ThisAddIn.ShowRibbonAppointment = true;
                newAppointment.Display(false);
                Globals.ThisAddIn.ShowRibbonAppointment = false;

                // Set ribbon control defaults
                findThisRibbon(); // This only works after message is displayed to user
                setRequireDisplayName();
                setStartWithAudioMuted();
                setStartWithVideoMuted();
                setRoomIdText(jitsiRoomId);
            }
            catch (Exception ex)
            {
                MessageBox.Show("The following error occurred: " + ex.Message);
            }
        }
Beispiel #4
0
 private void Explorer_ViewSwitch()
 {
     try
     {
         //HACK: Disable drag and drop hook when in calendar mode
         //For some reason dragging an item in calendar view throws E_NOINTERFACE exception when DoDragDrop COM function is hooked (thread issue?)
         Outlook.View view = this.Application.ActiveExplorer().CurrentView;
         if (view.ViewType == Outlook.OlViewType.olCalendarView)
         {
             StopHook();
         }
         else
         {
             StartHook();
         }
     }
     catch (Exception ex)
     {
         log.Fatal("Fatal error", ex);
         StopHook();
     }
 }
        // OnMyButtonClick routine handles all button click events
        // and displays IRibbonControl.Context in message box
        public void OnMyButtonClick(Office.IRibbonControl control)
        {
            string msg = string.Empty;

            if (control.Context is Outlook.AttachmentSelection)
            {
                msg = "Context=AttachmentSelection" + "\n";
                Outlook.AttachmentSelection attachSel =
                    control.Context as Outlook.AttachmentSelection;
                foreach (Outlook.Attachment attach in attachSel)
                {
                    msg = msg + attach.DisplayName + "\n";
                }
            }
            else if (control.Context is Outlook.Folder)
            {
                msg = "Context=Folder" + "\n";
                Outlook.Folder folder =
                    control.Context as Outlook.Folder;
                msg = msg + folder.Name;
            }
            else if (control.Context is Outlook.Selection)
            {
                msg = "Context=Selection" + "\n";
                Outlook.Selection selection =
                    control.Context as Outlook.Selection;
                if (selection.Count == 1)
                {
                    OutlookItem olItem =
                        new OutlookItem(selection[1]);
                    msg = msg + olItem.Subject
                          + "\n" + olItem.LastModificationTime;
                }
                else
                {
                    msg = msg + "Multiple Selection Count="
                          + selection.Count;
                }
            }
            else if (control.Context is Outlook.OutlookBarShortcut)
            {
                msg = "Context=OutlookBarShortcut" + "\n";
                Outlook.OutlookBarShortcut shortcut =
                    control.Context as Outlook.OutlookBarShortcut;
                msg = msg + shortcut.Name;
            }
            else if (control.Context is Outlook.Store)
            {
                msg = "Context=Store" + "\n";
                Outlook.Store store =
                    control.Context as Outlook.Store;
                msg = msg + store.DisplayName;
            }
            else if (control.Context is Outlook.View)
            {
                msg = "Context=View" + "\n";
                Outlook.View view =
                    control.Context as Outlook.View;
                msg = msg + view.Name;
            }
            else if (control.Context is Outlook.Inspector)
            {
                msg = "Context=Inspector" + "\n";
                Outlook.Inspector insp =
                    control.Context as Outlook.Inspector;
                if (insp.AttachmentSelection.Count >= 1)
                {
                    Outlook.AttachmentSelection attachSel =
                        insp.AttachmentSelection;
                    foreach (Outlook.Attachment attach in attachSel)
                    {
                        msg = msg + attach.DisplayName + "\n";
                    }
                }
                else
                {
                    OutlookItem olItem =
                        new OutlookItem(insp.CurrentItem);
                    msg = msg + olItem.Subject;
                }
            }
            else if (control.Context is Outlook.Explorer)
            {
                msg = "Context=Explorer" + "\n";
                Outlook.Explorer explorer =
                    control.Context as Outlook.Explorer;
                if (explorer.AttachmentSelection.Count >= 1)
                {
                    Outlook.AttachmentSelection attachSel =
                        explorer.AttachmentSelection;
                    foreach (Outlook.Attachment attach in attachSel)
                    {
                        msg = msg + attach.DisplayName + "\n";
                    }
                }
                else
                {
                    Outlook.Selection selection =
                        explorer.Selection;
                    if (selection.Count == 1)
                    {
                        OutlookItem olItem =
                            new OutlookItem(selection[1]);
                        msg = msg + olItem.Subject
                              + "\n" + olItem.LastModificationTime;
                    }
                    else
                    {
                        msg = msg + "Multiple Selection Count="
                              + selection.Count;
                    }
                }
            }
            else if (control.Context is Outlook.NavigationGroup)
            {
                msg = "Context=NavigationGroup" + "\n";
                Outlook.NavigationGroup navGroup =
                    control.Context as Outlook.NavigationGroup;
                msg = msg + navGroup.Name;
            }
            else if (control.Context is
                     Microsoft.Office.Core.IMsoContactCard)
            {
                msg = "Context=IMsoContactCard" + "\n";
                Office.IMsoContactCard card =
                    control.Context as Office.IMsoContactCard;
                if (card.AddressType ==
                    Office.MsoContactCardAddressType.
                    msoContactCardAddressTypeOutlook)
                {
                    // IMSOContactCard.Address is AddressEntry.ID
                    Outlook.AddressEntry addr =
                        Globals.ThisAddIn.Application.Session.GetAddressEntryFromID(
                            card.Address);
                    if (addr != null)
                    {
                        msg = msg + addr.Name;
                    }
                }
            }
            else if (control.Context is Outlook.NavigationModule)
            {
                msg = "Context=NavigationModule";
            }
            else if (control.Context == null)
            {
                msg = "Context=Null";
            }
            else
            {
                msg = "Context=Unknown";
            }
            MessageBox.Show(msg,
                            "RibbonXOutlook14AddinCS",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Information);
        }
Beispiel #6
0
        public void OnActionMyButton_Click(Office.IRibbonControl control)
        {
            // Get selected calendar date
            Outlook.Application application = new Outlook.Application();
            Outlook.Explorer    explorer    = application.ActiveExplorer();
            Outlook.Folder      folder      = explorer.CurrentFolder as Outlook.Folder;
            Outlook.View        view        = explorer.CurrentView as Outlook.View;
            String recip_mail   = null;
            String title_mail   = null;
            String content_mail = null;

            if (view.ViewType == Outlook.OlViewType.olCalendarView)
            {
                //Outlook.CalendarView calView = view as Outlook.CalendarView;
                //DateTime calDateStart = calView.SelectedStartTime;
                //DateTime calDateEnd = calView.SelectedEndTime;

                // Do stuff with dates.
                //MessageBox.Show("relance test"+ calDateStart+"---"+ calDateEnd);

                const string PR_SMTP_ADDRESS = "http://schemas.microsoft.com/mapi/proptag/0x39FE001E";
                try
                {
                    if (application.ActiveExplorer().Selection.Count > 0)
                    {
                        Object selObject = application.ActiveExplorer().Selection[1];


                        if (selObject is Outlook.AppointmentItem)
                        {
                            Outlook.AppointmentItem apptItem =
                                (selObject as Outlook.AppointmentItem);
                            title_mail   = apptItem.Subject;
                            content_mail = apptItem.Body;
                            Outlook.Recipients recips = apptItem.Recipients;
                            string             str    = null;

                            foreach (Outlook.Recipient recip in recips)
                            {
                                if (recip.MeetingResponseStatus != Outlook.OlResponseStatus.olResponseAccepted)
                                {
                                    Outlook.PropertyAccessor pa = recip.PropertyAccessor;
                                    string smtpAddress          =
                                        pa.GetProperty(PR_SMTP_ADDRESS).ToString();
                                    str += smtpAddress + ";";
                                }
                            }
                            if (str != null)
                            {
                                recip_mail = str;
                                //MessageBox.Show("Not responded: " + recip_mail);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                }
                //MessageBox.Show("infomation: " + recip_mail+";"+ title_mail+";"+content_mail);
                if (recip_mail != null && title_mail != null && content_mail != null)
                {
                    sendMail(recip_mail, title_mail, content_mail);
                }
            }
        }
 public void ViewContextMenuDisplay(CommandBar CommandBar, Outlook.View View)
 {
     Utility.LogApplicationEvent(LogType.Event, (string.Format("{0}{1}", new StackTrace().GetFrame(0).GetMethod().Name, System.Environment.NewLine)));
 }