using System; using Outlook = Microsoft.Office.Interop.Outlook; using System.Windows.Forms; using System.Runtime.InteropServices; namespace ManageSharedMailbox { public partial class MSMAddIn { private void ThisAddIn_Startup(object sender, System.EventArgs e){ PrepareRibbons(); } private void ThisAddIn_Shutdown(object sender, System.EventArgs e){} private void InternalStartup(){ this.Startup += new System.EventHandler(ThisAddIn_Startup); this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown); } private void PrepareRibbons() { const string PomijanePrefixy = "!@#$%^&*()_+=[]{};':\",./<>?|\\`~ "; const string PomijaneNazwy = "|archiwum|itemprocsearch|folder nadrzędny folderów osobistych|folder główny wyszukiwania|ipm_common_views|foldery wyszukiwania|freebusy data|"; foreach (Outlook.Folder folder in Application.Session.Folders) { if (null == folder.Store) continue; if (!folder.Store.IsOpen) continue; Outlook.OlExchangeStoreType storetype = folder.Store.ExchangeStoreType; if (storetype == Outlook.OlExchangeStoreType.olExchangePublicFolder) continue; if (storetype != Outlook.OlExchangeStoreType.olExchangeMailbox) continue; // I skip connected mailboxes without "SHARED" text in name if (!folder.Name.ToLower().Contains("shared")) continue; Outlook.MAPIFolder ofInbox = folder.Store.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox); if (null == ofInbox) continue; foreach (Outlook.Folder folderQuery in folder.Folders) { if (folderQuery.DefaultItemType != Outlook.OlItemType.olMailItem) continue; // I parse only INBOX folder if (folderQuery.EntryID != ofInbox.EntryID) continue; foreach (var item in folderQuery.Items) { // Works, I can iterate through emails (not folders!) in this folder } foreach (Outlook.Folder folderEntries in folderQuery.Folders) { // This collection is always empty, // regardless of how many subfolders // I have in the Inbox folder selected shared mailbox // How to fill that collection ? // or get list of these folders ? } break; } if (null != ofInbox) Marshal.ReleaseComObject(ofInbox); } } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)