none
Excluding public folders when enumerating Outlook folders RRS feed

  • Question

  • I have an Outlook plugin that searches all Outlook folders for certain information.

    However, some users have been complaining that the plugin searches public folders as well, which are huge in certain corporations, and that in turn makes the search very slow.

    I now use the following mechanism to search Outlook folders:

    NameSpace nameSpace = outlookApp.GetNamespace("MAPI");
                Folders accountFolders = nameSpace.Folders;
    
                try
                {
                    if (nameSpace == null || accountFolders == null)
                        return null;
                    for (int i = 1; i <= accountFolders.Count; i++)
                    {
                        MAPIFolder accountFolder = accountFolders.Item(i);
                        MailItem res = null;
                        try
                        {
                            res = ScanFolder(accountFolder, mailId, scanUI);
                        }
                        finally
                        {
                            if (accountFolder != null) Marshal.ReleaseComObject(accountFolder);
                        }
    
                        if (res != null) return res;
                    }
    
                    return null;
                }
                finally
                {
                    if (accountFolders != null) Marshal.ReleaseComObject(accountFolders);
                    if (nameSpace != null) Marshal.ReleaseComObject(nameSpace);
                }

    I've tried to look at the MAPIFolder object, but I didn't find any flag that could help me distinguish standard folders from public folders. Is there a way to do that?

    Thanks,

    Jan

    Thursday, March 26, 2015 10:12 AM

Answers

  • Hello Jan,

    The Outlook object model doesn't provide any property or method for that. You can use any low-level property viewer tool such as MFCMAPI or OutlookSpy to compare properties set on folders and find any differences.

    Be aware, you can use the  GetDefaultFolder method of the Store or Namespace class to get the All Public Folders folder in the Exchange Public Folders store. Only available for an Exchange account, see olPublicFoldersAllPublicFolders .  The difference is that Store.GetDefaultFolder method gets the default folder on the delivery store that is associated with the account, whereas NameSpace.GetDefaultFolder returns the default folder on the default store for the current profile.

    Thursday, March 26, 2015 11:59 AM
  • Read the PR_MDB_PROVIDER property (DASL name http://schemas.microsoft.com/mapi/proptag/0x34140102) using MAPIFolder.PropertyAccessor.GetProperty, convert it to hex using MAPIFolder.PropertyAccessor.BinaryToString. For the PF store objects, PR_MDB_PROVIDER property will be pbExchangeProviderPublicGuid (78B2FA70AFF711CD9BC800AA002FC45A) - you can see that property (and others) in OutlookSpy: click IMAPIFolder button.

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!



    Thursday, March 26, 2015 4:49 PM

All replies

  • Hello Jan,

    The Outlook object model doesn't provide any property or method for that. You can use any low-level property viewer tool such as MFCMAPI or OutlookSpy to compare properties set on folders and find any differences.

    Be aware, you can use the  GetDefaultFolder method of the Store or Namespace class to get the All Public Folders folder in the Exchange Public Folders store. Only available for an Exchange account, see olPublicFoldersAllPublicFolders .  The difference is that Store.GetDefaultFolder method gets the default folder on the delivery store that is associated with the account, whereas NameSpace.GetDefaultFolder returns the default folder on the default store for the current profile.

    Thursday, March 26, 2015 11:59 AM
  • Read the PR_MDB_PROVIDER property (DASL name http://schemas.microsoft.com/mapi/proptag/0x34140102) using MAPIFolder.PropertyAccessor.GetProperty, convert it to hex using MAPIFolder.PropertyAccessor.BinaryToString. For the PF store objects, PR_MDB_PROVIDER property will be pbExchangeProviderPublicGuid (78B2FA70AFF711CD9BC800AA002FC45A) - you can see that property (and others) in OutlookSpy: click IMAPIFolder button.

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!



    Thursday, March 26, 2015 4:49 PM