Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            Outlook.Application application = COMObject.CreateByRunningInstance <Outlook.Application>();

            // Get inbox
            Outlook._NameSpace outlookNS   = application.GetNamespace("MAPI");
            Outlook.MAPIFolder inboxFolder = outlookNS.GetDefaultFolder(OlDefaultFolders.olFolderInbox);

            for (int i = 1; i <= 100; i++)
            {
                labelCurrentCount.Text = "Step " + i.ToString();
                Application.DoEvents();
                if (_cancel)
                {
                    break;
                }

                // fetch inbox
                ListInBoxFolder(inboxFolder);
            }

            labelCurrentCount.Text = "Done!";

            // close outlook and dispose
            if (application.FromProxyService)
            {
                application.Quit();
            }
            application.Dispose();
        }
Esempio n. 2
0
        private void buttonStartExample_Click(object sender, EventArgs e)
        {
            // start outlook by trying to access running application first
            Outlook.Application outlookApplication = COMObject.CreateByRunningInstance <Outlook.Application>();

            // enum contacts
            int i = 0;

            Outlook.MAPIFolder contactFolder = outlookApplication.Session.GetDefaultFolder(OlDefaultFolders.olFolderContacts);
            foreach (ICOMObject item in contactFolder.Items)
            {
                Outlook.ContactItem contact = item as Outlook.ContactItem;
                if (null != contact)
                {
                    i++;
                    ListViewItem listItem = listViewContacts.Items.Add(i.ToString());
                    listItem.SubItems.Add(contact.CompanyAndFullName);
                }
            }

            // close outlook and dispose
            if (!outlookApplication.FromProxyService)
            {
                outlookApplication.Quit();
            }
            outlookApplication.Dispose();
        }
Esempio n. 3
0
 /// <summary>
 /// Occurs when Outlook quits.
 /// </summary>
 private static void Outlook_Quit()
 {
     s_outlookApplication.QuitEvent -= Outlook_Quit;
     s_outlookApplication.Dispose();
     s_outlookApplication = null;
     s_mapiFolder = null;
 }
Esempio n. 4
0
        private void buttonStartExample_Click(object sender, EventArgs e)
        {
            // start outlook
            Outlook.Application outlookApplication = new Outlook.Application();

            // get inbox
            Outlook._NameSpace outlookNS   = outlookApplication.GetNamespace("MAPI");
            Outlook.MAPIFolder inboxFolder = outlookNS.GetDefaultFolder(OlDefaultFolders.olFolderInbox);

            // setup gui
            listViewInboxFolder.Items.Clear();
            labelItemsCount.Text = string.Format("You have {0} e-mails.", inboxFolder.Items.Count);

            // we fetch the inbox folder items.
            foreach (COMObject item in inboxFolder.Items)
            {
                // not every item in the inbox is a mail item
                Outlook.MailItem mailItem = item as Outlook.MailItem;
                if (null != mailItem)
                {
                    ListViewItem newItem = listViewInboxFolder.Items.Add(mailItem.SenderName);
                    newItem.SubItems.Add(mailItem.Subject);
                }
            }

            // close outlook and dispose
            outlookApplication.Quit();
            outlookApplication.Dispose();
        }
Esempio n. 5
0
        private void buttonStartExample_Click(object sender, EventArgs e)
        {
            // start outlook by trying to access running application first
            Outlook.Application outlookApplication = new Outlook.Application(true);

            // get inbox
            Outlook._NameSpace outlookNS   = outlookApplication.GetNamespace("MAPI");
            Outlook.MAPIFolder inboxFolder = outlookNS.GetDefaultFolder(OlDefaultFolders.olFolderInbox);

            // setup ui
            listViewInboxFolder.Items.Clear();
            labelItemsCount.Text = string.Format("You have {0} e-mail(s).", inboxFolder.Items.Count);

            // we fetch the inbox folder items by a custom enumerator
            foreach (ICOMObject item in inboxFolder.Items)
            {
                // not every item in the inbox is a mail item
                Outlook.MailItem mailItem = item as Outlook.MailItem;
                if (null != mailItem)
                {
                    ListViewItem newItem = listViewInboxFolder.Items.Add(mailItem.SenderName);
                    newItem.SubItems.Add(mailItem.Subject);
                }
            }

            // close outlook and dispose
            if (!outlookApplication.FromProxyService)
            {
                outlookApplication.Quit();
            }
            outlookApplication.Dispose();
        }
Esempio n. 6
0
        public TestResult DoTest()
        {
            Outlook.Application application = null;
            DateTime            startTime   = DateTime.Now;

            try
            {
                // start outlook
                application = new Outlook.Application(true);
                NetOffice.OutlookSecurity.Suppress.Enabled = true;

                // Get inbox
                Outlook._NameSpace outlookNS   = application.GetNamespace("MAPI");
                Outlook.MAPIFolder inboxFolder = outlookNS.GetDefaultFolder(OlDefaultFolders.olFolderInbox);

                Outlook._Items items = inboxFolder.Items;
                COMObject      item  = null;
                int            i     = 1;
                do
                {
                    if (null == item)
                    {
                        item = items.GetFirst() as COMObject;
                    }

                    // not every item is a mail item
                    Outlook.MailItem mailItem = item as Outlook.MailItem;
                    if (null != mailItem)
                    {
                        Console.WriteLine(mailItem.SenderName);
                    }

                    if (null != item)
                    {
                        item.Dispose();
                    }

                    item = items.GetNext() as COMObject;
                    i++;
                } while (null != item);

                return(new TestResult(true, DateTime.Now.Subtract(startTime), "", null, string.Format("{0} Inbox Items.", items.Count)));
            }
            catch (Exception exception)
            {
                return(new TestResult(false, DateTime.Now.Subtract(startTime), exception.Message, exception, ""));
            }
            finally
            {
                if (null != application)
                {
                    if (!application.FromProxyService)
                    {
                        application.Quit();
                    }
                    application.Dispose();
                }
            }
        }
Esempio n. 7
0
        public Outlok()
        {
            NetOffice.OutlookApi.Application outlookApplication = new Outlook.Application();
            outlookApplication.NewMailExEvent += new Outlook.Application_NewMailExEventHandler(outlook_newmail);
            outlookNS = outlookApplication.Session;

            inboxFolder = outlookNS.Folders["*****@*****.**"].Folders["Inbox"];
            einbuchung  = outlookNS.Folders["*****@*****.**"].Folders["[Gmail]"].Folders["DevDB"].Folders["Einbuchung"];
            ausbuchung  = outlookNS.Folders["*****@*****.**"].Folders["[Gmail]"].Folders["DevDB"].Folders["Ausbuchung"];
        }
        private void Initialize()
        {
            outlookApp = new Outlook.Application();

            outlookNS   = outlookApp.GetNamespace("MAPI");
            inboxFolder = outlookNS.GetDefaultFolder(OlDefaultFolders.olFolderInbox);

            items = (Outlook.Items)inboxFolder.Items;
            items.ItemAddEvent +=
                new Outlook.Items_ItemAddEventHandler(items_ItemAdd);
        }
Esempio n. 9
0
 private void TraverseFolders(Outlook.MAPIFolder parentFolder)
 {
     foreach (Outlook.MAPIFolder folder in parentFolder.Folders)
     {
         if (folder.DefaultItemType == Outlook.Enums.OlItemType.olContactItem)
         {
             txtResults.AppendText(string.Format("{0} - {1} [{2}]\r\n", folder.Name, folder.DefaultItemType, folder.EntryID));
             TraverseFolders(folder);
         }
     }
 }
Esempio n. 10
0
        private void CreateAppointment(WorkShift workShift)
        {
            if (!workShift.IsValidForCalendar)
            {
                Console.WriteLine("Des erreurs ont été trouvé lors du parsing des shifts. Impossible de créer un rendez-vous pour #" + workShift.ShiftPosition);
                return;
            }

            Outlook.MAPIFolder primaryCalendar = (Outlook.MAPIFolder)
                                                 thisOutlookApp.ActiveExplorer().Session.GetDefaultFolder
                                                     (OlDefaultFolders.olFolderCalendar);

            Outlook.MAPIFolder familialCalendar = null;
            foreach (Outlook.MAPIFolder personalCalendar in primaryCalendar.Folders)
            {
                if (personalCalendar.Name == "familial")
                {
                    familialCalendar = personalCalendar;
                    break;
                }
            }

            if (familialCalendar == null)
            {
                Console.WriteLine("Impossible de créer un rendez-vous pour le shift #" + workShift.ShiftPosition + " : Calendrier Familial non trouvé.");
                return;
            }

            Outlook.AppointmentItem newAppointment = (Outlook.AppointmentItem)familialCalendar.Items.Add(OlItemType.olAppointmentItem);

            newAppointment.Start    = workShift.StartingShiftDate;
            newAppointment.End      = workShift.FinishingShiftDate;
            newAppointment.Location = workShift.Location;
            newAppointment.Body     = string.Empty;
            foreach (var type in workShift.typeOfShift)
            {
                newAppointment.Body += "Shift de " + type.ShiftTitle + " : " + type.ShiftDescription + "\n";
            }

            newAppointment.AllDayEvent = false;
            newAppointment.Subject     = "Travail McDonald's " + EmpName;

            Outlook.Items calendarItems = (Outlook.Items)familialCalendar.Items;

            newAppointment.Save();

            Console.WriteLine("Shift " + workShift.ShiftPosition + " enregistré avec succès!");
        }
Esempio n. 11
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            if (m_app == null)
            {
                m_app = new Outlook.Application();
                Outlook._NameSpace ns = m_app.GetNamespace("MAPI");

                foreach (Outlook.MAPIFolder folder in ns.Folders)
                {
                    txtResults.AppendText(string.Format("{0} - {1}\r\n", folder.Name, folder.DefaultItemType));
                    TraverseFolders(folder);
                }

                Outlook.MAPIFolder selectedFolder = ns.GetFolderFromID("00000000C5B7DEF515463948B280312D7005404A02870000");

                foreach (object oItem in selectedFolder.Items)
                {
                    if (oItem is Outlook.ContactItem)
                    {
                        Outlook.ContactItem item = (Outlook.ContactItem)oItem;

                        txtResults.AppendText(string.Format("{0}/{1}\r\n", item.FirstName, item.LastName));

                        if (string.Equals("LastName", item.LastName))
                        {
                            propertyGrid1.SelectedObject = item;

                            var props = TypeDescriptor.GetProperties(item);
                            foreach (PropertyDescriptor prop in props)
                            {
                                try
                                {
                                    txtResults.AppendText(string.Format("{0} : {1}\r\n", prop.DisplayName, prop.GetValue(item)));
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.Message);
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 12
0
        static void Main(string[] args)
        {
            // start outlook
            outlookApplication = new Outlook.Application();
            devdb = new MySqlConnection(@"Server=127.0.0.1;Uid=root;Pwd=;Database=devdb;");

            // get inbox
            outlookNS   = outlookApplication.Session;
            inboxFolder = outlookNS.Folders["*****@*****.**"].Folders["Inbox"];

            einbuchung = outlookNS.Folders["*****@*****.**"].Folders["[Gmail]"].Folders["DevDB"].Folders["Einbuchung"];
            Outlook.MAPIFolder ausbuchung = outlookNS.Folders["*****@*****.**"].Folders["[Gmail]"].Folders["DevDB"].Folders["Ausbuchung"];


            outlookApplication.NewMailExEvent += new Outlook.Application_NewMailExEventHandler(outlook_newmail);                // Initializing both Event Handlers
            outlookApplication.Session.SyncObjects[1].SyncEndEvent += new Outlook.SyncObject_SyncEndEventHandler(sync_end);

            while (true)
            {
            }
        }
Esempio n. 13
0
 private void Menu_ItemClick(object sender, TrayMenuItemsEventArgs args)
 {
     // See what happen in tray proxy live monitor
     if (args.Item.Text == "Fetch inbox(first 20)")
     {
         Outlook._NameSpace outlookNS   = Application.GetNamespace("MAPI");
         Outlook.MAPIFolder inboxFolder = outlookNS.GetDefaultFolder(OlDefaultFolders.olFolderInbox);
         for (int i = 1; i < inboxFolder.Items.Count; i++)
         {
             object item = inboxFolder.Items[i];
             if (i == 20)
             {
                 break;
             }
         }
     }
     else if (args.Item.Text == "Dispose all application child proxies")
     {
         Application.DisposeChildInstances();
     }
 }
Esempio n. 14
0
        public TestResult DoTest()
        {
            Outlook.Application application = null;
            DateTime            startTime   = DateTime.Now;

            try
            {
                // start outlook
                application = COMObject.CreateByRunningInstance <Outlook.Application>(COMObjectCreateOptions.CreateNewCore);
                NetOffice.OutlookSecurity.Suppress.Enabled = true;

                // enum contacts
                Outlook.MAPIFolder contactFolder = application.Session.GetDefaultFolder(OlDefaultFolders.olFolderContacts);
                for (int i = 1; i <= contactFolder.Items.Count; i++)
                {
                    Outlook.ContactItem contact = contactFolder.Items[i] as Outlook.ContactItem;
                    if (null != contact)
                    {
                        Console.WriteLine(contact.CompanyAndFullName);
                    }
                }

                return(new TestResult(true, DateTime.Now.Subtract(startTime), "", null, string.Format("{0} ContactFolder Items.", contactFolder.Items.Count)));
            }
            catch (Exception exception)
            {
                return(new TestResult(false, DateTime.Now.Subtract(startTime), exception.Message, exception, ""));
            }
            finally
            {
                if (null != application)
                {
                    if (!application.FromProxyService)
                    {
                        application.Quit();
                    }
                    application.Dispose();
                }
            }
        }
Esempio n. 15
0
        private void ListInBoxFolder(Outlook.MAPIFolder inboxFolder)
        {
            // setup ui
            listView1.Items.Clear();

            // we fetch the inbox folder items
            Outlook._Items items = inboxFolder.Items;
            ICOMObject     item  = null;
            int            i     = 1;

            do
            {
                if (null == item)
                {
                    item = items.GetFirst() as ICOMObject;
                    if (null == item)
                    {
                        break;
                    }
                }

                // not every item is a mail item
                Outlook.MailItem mailItem = item as Outlook.MailItem;
                if (null != mailItem)
                {
                    ListViewItem newItem = listView1.Items.Add(mailItem.SenderName);
                    newItem.SubItems.Add(mailItem.Subject);
                }

                item.Dispose();
                item = items.GetNext() as ICOMObject;
                i++;
            } while (null != item);

            // dipsose items and childs
            items.Dispose();
        }
Esempio n. 16
0
        private void buttonStartExample_Click(object sender, EventArgs e)
        {
            // start outlook
            Outlook.Application outlookApplication = new Outlook.Application();

            // enum contacts
            int i = 0;

            Outlook.MAPIFolder contactFolder = outlookApplication.Session.GetDefaultFolder(OlDefaultFolders.olFolderContacts);
            foreach (COMObject item in contactFolder.Items)
            {
                Outlook.ContactItem contact = item as Outlook.ContactItem;
                if (null != contact)
                {
                    i++;
                    ListViewItem listItem = listViewContacts.Items.Add(i.ToString());
                    listItem.SubItems.Add(contact.CompanyAndFullName);
                }
            }

            // close outlook and dispose
            outlookApplication.Quit();
            outlookApplication.Dispose();
        }
Esempio n. 17
0
        private void buttonStartExample_Click(object sender, EventArgs e)
        {
            // start outlook
            _outlookApplication = new Outlook.Application();

            Office.CommandBar       commandBar    = null;
            Office.CommandBarButton commandBarBtn = null;

            Outlook._NameSpace outlookNS   = _outlookApplication.GetNamespace("MAPI");
            Outlook.MAPIFolder inboxFolder = outlookNS.GetDefaultFolder(OlDefaultFolders.olFolderInbox);
            inboxFolder.Display();

            // add a commandbar popup
            Office.CommandBarPopup commandBarPopup = (Office.CommandBarPopup)_outlookApplication.ActiveExplorer().CommandBars["Menu Bar"].Controls.Add(MsoControlType.msoControlPopup, System.Type.Missing, System.Type.Missing, System.Type.Missing, true);
            commandBarPopup.Caption = "commandBarPopup";

            #region few words, how to access the picture

            /*
             * you can see we use an own icon via .PasteFace()
             * is not possible from outside process boundaries to use the PictureProperty directly
             * the reason for is IPictureDisp: http://support.microsoft.com/kb/286460/de
             * its not important is early or late binding or managed or unmanaged, the behaviour is always the same
             * For example, a COMAddin running as InProcServer and can access the Picture Property
             */
            #endregion

            #region CommandBarButton

            // add a button to the popup
            commandBarBtn         = (Office.CommandBarButton)commandBarPopup.Controls.Add(MsoControlType.msoControlButton, System.Type.Missing, System.Type.Missing, System.Type.Missing, true);
            commandBarBtn.Style   = MsoButtonStyle.msoButtonIconAndCaption;
            commandBarBtn.Caption = "commandBarButton";
            Clipboard.SetDataObject(_hostApplication.DisplayIcon.ToBitmap());
            commandBarBtn.PasteFace();
            commandBarBtn.ClickEvent += new Office.CommandBarButton_ClickEventHandler(commandBarBtn_Click);

            #endregion

            #region Create a new toolbar

            // add a new toolbar
            commandBar         = _outlookApplication.ActiveExplorer().CommandBars.Add("MyCommandBar", MsoBarPosition.msoBarTop, false, true);
            commandBar.Visible = true;

            // add a button to the toolbar
            commandBarBtn             = (Office.CommandBarButton)commandBar.Controls.Add(MsoControlType.msoControlButton, System.Type.Missing, System.Type.Missing, System.Type.Missing, true);
            commandBarBtn.Style       = MsoButtonStyle.msoButtonIconAndCaption;
            commandBarBtn.Caption     = "commandBarButton";
            commandBarBtn.FaceId      = 3;
            commandBarBtn.ClickEvent += new Office.CommandBarButton_ClickEventHandler(commandBarBtn_Click);

            // add a dropdown box to the toolbar
            commandBarPopup         = (Office.CommandBarPopup)commandBar.Controls.Add(MsoControlType.msoControlPopup, System.Type.Missing, System.Type.Missing, System.Type.Missing, true);
            commandBarPopup.Caption = "commandBarPopup";

            // add a button to the popup, we use an own icon for the button
            commandBarBtn         = (Office.CommandBarButton)commandBarPopup.Controls.Add(MsoControlType.msoControlButton, System.Type.Missing, System.Type.Missing, System.Type.Missing, true);
            commandBarBtn.Style   = MsoButtonStyle.msoButtonIconAndCaption;
            commandBarBtn.Caption = "commandBarButton";
            Clipboard.SetDataObject(_hostApplication.DisplayIcon.ToBitmap());
            commandBarBtn.PasteFace();
            commandBarBtn.ClickEvent += new Office.CommandBarButton_ClickEventHandler(commandBarBtn_Click);

            #endregion

            // set buttons
            buttonStartExample.Enabled = false;
            buttonQuitExample.Enabled  = true;
        }
Esempio n. 18
0
 public virtual NetOffice.OutlookApi.NavigationFolder Add(NetOffice.OutlookApi.MAPIFolder folder)
 {
     return(InvokerService.InvokeInternal.ExecuteKnownReferenceMethodGet <NetOffice.OutlookApi.NavigationFolder>(this, "Add", typeof(NetOffice.OutlookApi.NavigationFolder), folder));
 }
Esempio n. 19
0
 public virtual bool IsFolderSelected(NetOffice.OutlookApi.MAPIFolder folder)
 {
     return(InvokerService.InvokeInternal.ExecuteBoolMethodGet(this, "IsFolderSelected", folder));
 }
Esempio n. 20
0
 /// <summary>
 /// Gets true if the Outlook calendar exist.
 /// </summary>
 /// <param name="useDefaultCalendar">if set to <c>true</c> [use default calendar].</param>
 /// <param name="path">The path.</param>
 /// <returns></returns>
 internal static bool OutlookCalendarExist(bool useDefaultCalendar, string path = null)
 {
     s_mapiFolder = null;
     return GetMapiFolder(OutlookApplication.Session.Folders, useDefaultCalendar, path);
 }
Esempio n. 21
0
 public virtual void AddSolution(NetOffice.OutlookApi.MAPIFolder solution, NetOffice.OutlookApi.Enums.OlSolutionScope scope)
 {
     InvokerService.InvokeInternal.ExecuteMethod(this, "AddSolution", solution, scope);
 }
Esempio n. 22
0
 private void Mapi_OptionsPagesAddEvent(Outlook.PropertyPages pages, Outlook.MAPIFolder folder)
 {
 }
Esempio n. 23
0
 public virtual void RemoveStore(NetOffice.OutlookApi.MAPIFolder folder)
 {
     InvokerService.InvokeInternal.ExecuteMethod(this, "RemoveStore", folder);
 }
Esempio n. 24
0
        public TestResult DoTest()
        {
            Outlook.Application application = null;
            DateTime            startTime   = DateTime.Now;

            try
            {
                Bitmap iconBitmap = new Bitmap(System.Reflection.Assembly.GetAssembly(this.GetType()).GetManifestResourceStream("OutlookTestsCSharp.Test07.bmp"));

                // start outlook
                application = new Outlook.Application();
                NetOffice.OutlookSecurity.Suppress.Enabled = true;

                Office.CommandBar       commandBar;
                Office.CommandBarButton commandBarBtn;

                Outlook._NameSpace outlookNS   = application.GetNamespace("MAPI");
                Outlook.MAPIFolder inboxFolder = outlookNS.GetDefaultFolder(OlDefaultFolders.olFolderInbox);
                inboxFolder.Display();

                // add a commandbar popup
                Office.CommandBarPopup commandBarPopup = (Office.CommandBarPopup)application.ActiveExplorer().CommandBars["Menu Bar"].Controls.Add(MsoControlType.msoControlPopup, System.Type.Missing, System.Type.Missing, System.Type.Missing, true);
                commandBarPopup.Caption = "commandBarPopup";

                #region CommandBarButton

                // add a button to the popup
                commandBarBtn         = (Office.CommandBarButton)commandBarPopup.Controls.Add(MsoControlType.msoControlButton, System.Type.Missing, System.Type.Missing, System.Type.Missing, true);
                commandBarBtn.Style   = MsoButtonStyle.msoButtonIconAndCaption;
                commandBarBtn.Caption = "commandBarButton";
                Clipboard.SetDataObject(iconBitmap);
                commandBarBtn.PasteFace();
                commandBarBtn.ClickEvent += new Office.CommandBarButton_ClickEventHandler(commandBarBtn_Click);

                #endregion

                #region Create a new toolbar

                // add a new toolbar
                commandBar         = application.ActiveExplorer().CommandBars.Add("MyCommandBar", MsoBarPosition.msoBarTop, false, true);
                commandBar.Visible = true;

                // add a button to the toolbar
                commandBarBtn             = (Office.CommandBarButton)commandBar.Controls.Add(MsoControlType.msoControlButton, System.Type.Missing, System.Type.Missing, System.Type.Missing, true);
                commandBarBtn.Style       = MsoButtonStyle.msoButtonIconAndCaption;
                commandBarBtn.Caption     = "commandBarButton";
                commandBarBtn.FaceId      = 3;
                commandBarBtn.ClickEvent += new Office.CommandBarButton_ClickEventHandler(commandBarBtn_Click);

                // add a dropdown box to the toolbar
                commandBarPopup         = (Office.CommandBarPopup)commandBar.Controls.Add(MsoControlType.msoControlPopup, System.Type.Missing, System.Type.Missing, System.Type.Missing, true);
                commandBarPopup.Caption = "commandBarPopup";

                // add a button to the popup, we use an own icon for the button
                commandBarBtn         = (Office.CommandBarButton)commandBarPopup.Controls.Add(MsoControlType.msoControlButton, System.Type.Missing, System.Type.Missing, System.Type.Missing, true);
                commandBarBtn.Style   = MsoButtonStyle.msoButtonIconAndCaption;
                commandBarBtn.Caption = "commandBarButton";
                Clipboard.SetDataObject(iconBitmap);
                commandBarBtn.PasteFace();
                commandBarBtn.ClickEvent += new Office.CommandBarButton_ClickEventHandler(commandBarBtn_Click);

                #endregion

                return(new TestResult(true, DateTime.Now.Subtract(startTime), "", null, ""));
            }
            catch (Exception exception)
            {
                return(new TestResult(false, DateTime.Now.Subtract(startTime), exception.Message, exception, ""));
            }
            finally
            {
                if (null != application)
                {
                    application.Quit();
                    application.Dispose();
                }
            }
        }
Esempio n. 25
0
        /// <summary>
        /// Gets the mapi folder.
        /// </summary>
        /// <param name="folders">The folders.</param>
        /// <param name="useDefaultCalendar">if set to <c>true</c> [use default calendar].</param>
        /// <param name="path">The path.</param>
        /// <returns></returns>
        private static bool GetMapiFolder(IEnumerable folders, bool useDefaultCalendar = false, string path = null)
        {
            if (useDefaultCalendar)
            {
                s_mapiFolder = OutlookApplication.Session.GetDefaultFolder(OlDefaultFolders.olFolderCalendar);
                return s_mapiFolder != null;
            }

            if (String.IsNullOrWhiteSpace(path))
                path = Settings.Calendar.OutlookCustomCalendarPath;

            if (!path.StartsWith(@"\\", StringComparison.Ordinal))
                return s_mapiFolder != null;

            string pathRoot = GetFolderPathRoot(path);

            foreach (MAPIFolder folder in folders.Cast<MAPIFolder>().TakeWhile(
                folder => s_mapiFolder == null).Select(
                    folder => new { folder, folderRoot = GetFolderPathRoot(folder.FolderPath) }).Where(
                        folder => folder.folderRoot == pathRoot).Select(folder => folder.folder))
            {
                if (folder.DefaultItemType == OlItemType.olAppointmentItem && folder.FolderPath == path)
                {
                    s_mapiFolder = folder;
                    break;
                }

                if (folder.Folders.Any())
                    GetMapiFolder(folder.Folders, path: path);
            }

            return s_mapiFolder != null && s_mapiFolder.FolderPath == path;
        }
Esempio n. 26
0
        private void comboBox1_SelectedValueChanged(object sender, EventArgs e)
        {
            var item = ((ComboBox)sender).SelectedItem;

            currentFolder = ((Item)item).Value;
        }
Esempio n. 27
0
 public Item(Outlook.MAPIFolder value)
 {
     Value = value;
 }
Esempio n. 28
0
 public virtual void DeselectFolder(NetOffice.OutlookApi.MAPIFolder folder)
 {
     InvokerService.InvokeInternal.ExecuteMethod(this, "DeselectFolder", folder);
 }
Esempio n. 29
0
 public virtual NetOffice.OutlookApi.MAPIFolder CopyTo(NetOffice.OutlookApi.MAPIFolder destinationFolder)
 {
     return(InvokerService.InvokeInternal.ExecuteBaseReferenceMethodGet <NetOffice.OutlookApi.MAPIFolder>(this, "CopyTo", destinationFolder));
 }
Esempio n. 30
0
 public virtual void MoveTo(NetOffice.OutlookApi.MAPIFolder destinationFolder)
 {
     InvokerService.InvokeInternal.ExecuteMethod(this, "MoveTo", destinationFolder);
 }
Esempio n. 31
0
 public virtual object Move(NetOffice.OutlookApi.MAPIFolder destFldr)
 {
     return(InvokerService.InvokeInternal.ExecuteVariantMethodGet(this, "Move", destFldr));
 }
Esempio n. 32
0
 public virtual void SetAlwaysMoveToFolder(NetOffice.OutlookApi.MAPIFolder moveToFolder, NetOffice.OutlookApi._Store store)
 {
     InvokerService.InvokeInternal.ExecuteMethod(this, "SetAlwaysMoveToFolder", moveToFolder, store);
 }