private static void FindWellKnownFoldersWithinInbox(IMailbox mailbox, Dictionary <WellKnownFolderType, byte[]> wellKnownFolders) { byte[] receiveFolderEntryId = mailbox.GetReceiveFolderEntryId("IPM"); if (receiveFolderEntryId != null) { using (IFolder inbox = CommonUtils.GetFolder(mailbox, receiveFolderEntryId)) { if (inbox != null) { FolderHierarchyUtils.FindWellKnownFolders(mailbox, FolderHierarchyUtils.InboxRefs, (PropTag[] pta) => inbox.GetProps(pta), wellKnownFolders); } } } }
public static List <WellKnownFolder> DiscoverWellKnownFolders(IMailbox mailbox, int flags) { Dictionary <WellKnownFolderType, byte[]> dictionary = new Dictionary <WellKnownFolderType, byte[]>(); bool flag = ((FolderHierarchyFlags)flags).HasFlag(FolderHierarchyFlags.PublicFolderMailbox); FolderHierarchyUtils.FindWellKnownFolders(mailbox, flag ? FolderHierarchyUtils.PublicFolderMailboxRefs : FolderHierarchyUtils.MailboxRefs, (PropTag[] pta) => mailbox.GetProps(pta), dictionary); if (!flag) { FolderHierarchyUtils.FindWellKnownFoldersWithinInbox(mailbox, dictionary); } List <WellKnownFolder> list = new List <WellKnownFolder>(); foreach (KeyValuePair <WellKnownFolderType, byte[]> keyValuePair in dictionary) { list.Add(new WellKnownFolder((int)keyValuePair.Key, keyValuePair.Value)); } return(list); }