Accessing delegate folders RRS feed

  • Question

  • For a VSTO .Net plugin I have an Outlook account which has several other mailboxes opened as delegates (a restricted set of folders).

    I want to select a Calendar (entry) in a delegate and from that open another folder (Contacts).

    I can use the selected folder (CurrentFolder) and get to the Store which will give me a display name but this is not sufficient to do a recipient Resolve so I can open the other folder using GetSharedDefaultFolder

    Any ideas on how I can get to the other folder from CurrentFolder?

    Friday, August 25, 2017 8:00 AM

All replies

  • Hello James,

    The NameSpace.GetSharedDefaultFolder method returns Folder object that represents the specified default folder for the specified user. You can use the Folders property of the Folder class for navigating between folders in the store. Or use the Parent property for accessing the parent folder. See How to: Enumerate Folders for more information. 

    private void EnumerateFoldersInDefaultStore()
        Outlook.Folder root =
            DefaultStore.GetRootFolder() as Outlook.Folder;
    // Uses recursion to enumerate Outlook subfolders.
    private void EnumerateFolders(Outlook.Folder folder)
        Outlook.Folders childFolders =
        if (childFolders.Count > 0)
            foreach (Outlook.Folder childFolder in childFolders)
                // Write the folder path.
                // Call EnumerateFolders using childFolder.

    To bring the folder into the view you just need to set the CurrentFolder property of the Explorer class. 

    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    Friday, August 25, 2017 1:32 PM
  • Thanks. My issue is getting the identifier for the user so I can use it in GetSharedDefaultFolder

    If several delegate mailboxes are open and I select an item in the Calendar, how can I get the user so I can open another folder for that user, in my case the Contacts folder?

    All I can see for the selected item is the Store where I can get the "display name" which is not enough to get to a Resolved Recipient to use in GetSharedDefaultFolder.

    The Session.DefaultStore.GetRootFolder provides the root folder structure for the main account open in the profile not the attached delegated folders. I can't see how to traverse the object selected to get to the delegate user.

    Alternatively, if I could list the users (recipients) of the attached delegated mailboxes that would give a way forward.

    Friday, August 25, 2017 8:14 PM
  • Hello,

    The following code could work for me to access the contact when selecting a appointment as a delegate. Please test if it is what you want.  

    Sub accessDelegate()
    Dim myItem As AppointmentItem
    Set myItem = Application.ActiveInspector.currentItem
    Dim myNamespace As Outlook.NameSpace
    Set myNamespace = Application.GetNamespace("MAPI")
    Dim contactFolder As Outlook.Folder
    Set contactFolder = Application.ActiveExplorer.CurrentFolder.Store.GetDefaultFolder(olFolderContacts)
    End Sub



    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Monday, August 28, 2017 8:35 AM