none
Access Shared mailbox folder RRS feed

  • Question

  • Hi,
    I'm using Microsoft Exchange Web Services (in C#) to access a shared mailbox and read email messages. I want to know how do I list the folders in a shared mailbox? I'm able to list the folders in my mailbox, but not the shared mailbox.
    Here's the code I have so far:

    ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013);
    service.Credentials = new WebCredentials("userid", "password", "domain");
    service.Url = new System.Uri("https://exchangeServer/EWS/Exchange.asmx");
     FolderView view = new FolderView(100);
                view.PropertySet = new PropertySet(BasePropertySet.IdOnly);
                view.PropertySet.Add(FolderSchema.DisplayName);
                view.Traversal = FolderTraversal.Deep;
                FindFoldersResults findFolderResults = service.FindFolders(WellKnownFolderName.Root, view);
                foreach (Folder f in findFolderResults)
                {
                    if (f.DisplayName == "SomeFolder")
                        Console.WriteLine(f.Id);
                }
    


    The above code gives me the Folderids of all the folders in my mailbox.
    I have the below code to get the folderid of Inbox in the shared mailbox:

    Mailbox gpmailbox = new Mailbox("mailbox@yourdomainname.com");
    FolderId gpInbox = new FolderId(WellKnownFolderName.Inbox, gpmailbox);

    How do I get the list of folders (and folderids ) in the shared mailbox?


    Thank you


    Abhi

    Monday, February 24, 2014 6:17 PM

Answers

  • Sorry for the post. I found out how to do it.
       FolderView view = new FolderView(100);
                view.PropertySet = new PropertySet(BasePropertySet.IdOnly);
                view.PropertySet.Add(FolderSchema.DisplayName);
                view.Traversal = FolderTraversal.Deep;
                Mailbox mailbox = new Mailbox("mysharedmailbox@domain.com");
                FindFoldersResults findFolderResults = service.FindFolders(new FolderId(WellKnownFolderName.MsgFolderRoot, mailbox), view);
    
                foreach (Folder f in findFolderResults)
                {
                    Console.WriteLine(f.Id);
                }


    Abhi

    • Marked as answer by iconabhi114 Monday, February 24, 2014 7:35 PM
    Monday, February 24, 2014 7:35 PM