none
Opening a Public Folder in "Favorites" instead of "All Public Folders"? RRS feed

  • Question

  • For some reason since a public folder in favorites seems to perform searches better, I need to update the following code so it points to a public folder in favorites instead of "All Public Folders" but am not sure how to simply modify as such.  Here's my code which points to All public folders at least:

                string fldrnm = "D&M Rolodex";
                Outlook.NameSpace ns = Globals.ThisAddIn.Application.GetNamespace("MAPI");
                Outlook.MAPIFolder rootPublicfolder = ns.GetDefaultFolder(Outlook.OlDefaultFolders.olPublicFoldersAllPublicFolders);
                Globals.ThisAddIn.Application.ActiveExplorer().CurrentFolder = rootPublicfolder.Folders[fldrnm];

    Wednesday, February 13, 2013 9:14 PM

Answers

  • I don't know if there i a way to do that reliably in the Outlook Object Model, but you can

    1. Use Redemption - its version of GetDefaultFolder (RDOSession and RDOStore objects) has an extra default folder enum - olPublicFoldersFavorites.

    2. Retrieve the folder entry id (MAPIFolder.EntryID) - to the best of my knowledge, the entry id of a folder in the PF store is the same as the entry id of the same folder in Favorites, but byte 18 (36 if you are using the hex entry id) is 0 for the online version and 0x80 for the Favorites version. You can then re-open the cached version of the folder using Namespace.GetFolderFromID.


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



    Wednesday, February 13, 2013 9:29 PM
  • You can try that, but accessing any folder by name is bound to break if Outlook uses language other than English.

    Have you tried the entry id trick?


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

    Thursday, February 14, 2013 8:02 PM

All replies

  • I don't know if there i a way to do that reliably in the Outlook Object Model, but you can

    1. Use Redemption - its version of GetDefaultFolder (RDOSession and RDOStore objects) has an extra default folder enum - olPublicFoldersFavorites.

    2. Retrieve the folder entry id (MAPIFolder.EntryID) - to the best of my knowledge, the entry id of a folder in the PF store is the same as the entry id of the same folder in Favorites, but byte 18 (36 if you are using the hex entry id) is 0 for the online version and 0x80 for the Favorites version. You can then re-open the cached version of the folder using Namespace.GetFolderFromID.


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



    Wednesday, February 13, 2013 9:29 PM
  • I see Redemption is a third party provider, and since I don't want to install for up to 50 users, I was wondering if I could use something similar to another program that did something a bit similar, at least get to the public folder root level then find "Favorites"

    Actually this following lines of code seemed to work so far:

                Outlook.MAPIFolder rootPublicfolder = ns.GetDefaultFolder(Outlook.OlDefaultFolders.olPublicFoldersAllPublicFolders);
                rootPublicfolder = rootPublicfolder.Parent.Folders["Favorites"];

    • Edited by jfalberg Thursday, February 14, 2013 4:27 PM tried something a little different
    Thursday, February 14, 2013 2:53 PM
  • You can try that, but accessing any folder by name is bound to break if Outlook uses language other than English.

    Have you tried the entry id trick?


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

    Thursday, February 14, 2013 8:02 PM