Find all subfolders in Inbox folder using EWS RRS feed

  • Question

  • I have the following Inbox folder structure:

    ----ABC 2 
    ----ABC 3 
    ----XYZ 2 

    I am using Exchange Web Services and the following code to find the child folders of the Inbox folder:

    ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010); 
    Mailbox mb = new Mailbox(""); 
    FindFoldersResults findResults = service.FindFolders( 
    new FolderView(int.MaxValue)); 
    foreach (Folder folder in findResults.Folders) 

    This partly works because it returns the ABC, XYZ, and 123 folders; unfortunately, it does not return the folders inside each of those folders (ABC 2, ABC 3, XYZ 2, 123 A, 123 B, 123 C).

    Also, it is possible that a folder could have more than one level of subfolders inside it.

    How can I write this code so that it will return all subfolders regardless of how deeply nested they may be?

    Thursday, September 29, 2011 3:28 PM

All replies