Retrieving Search Folders with EWS RRS feed

  • Question

  • Hi,

    I already posted something about it, but the post got really long (here). Now my 2 questions are quite precise:

    What is the difference between a search folder created under Outlook and one created with EWS? (beside the filter conditions)

    Why can't I retrieve those created under Outlook with EWS?


    Thank you very much

    • Edited by RadigouTD Tuesday, February 22, 2011 10:30 AM Detail added
    Tuesday, February 22, 2011 10:29 AM


  • This shouldn't really matter but are you using Outlook in Cache mode ? What happens if you switch it to online mode and create a simple search folder.


    • Marked as answer by RadigouTD Friday, February 25, 2011 9:18 AM
    Friday, February 25, 2011 2:31 AM

All replies

  • 1. The restiction logic you can use with a EWS Searchfilter is a only a Subset of what can be used use in Mapi restriction this is talked about more in Inside Exchange Web Services http://my.safaribooksonline.com/book/email/microsoft-exchange-server/9780735623927 which is worth the investment if your doing a lot EWS coding.

    2. For a search folders to appear in Microsoft Office Outlook, Outlook Web App the folder must be created in the WellKnownFolderName.SearchFolders folder (this translates to the Finder folder in the NON_IPM_Subtree of a mailbox). So you can retrieve the search folders that Outlook creates from there.

    To find all search folders in mailbox you can use a query like this

    ExtendedPropertyDefinition PR_FOLDER_TYPE = new ExtendedPropertyDefinition(13825,MapiPropertyType.Integer);
    FolderView fv = new FolderView(1);
    fv.Traversal = FolderTraversal.Deep;
    SearchFilter sf1 = new SearchFilter.IsEqualTo(PR_FOLDER_TYPE, "2");
    FindFoldersResults ffResults = service.FindFolders(WellKnownFolderName.Root,sf1,fv);
    Wednesday, February 23, 2011 2:52 AM
  • Hi Glen, thank you for you reply,

    Search folders created under Outlook unfortunately don't show up with this code. (It retrieves 6 folders including 2 I made with EWS, the 4 others are: AllItems, Rappels, Spooler Queue, To-Do Search but none of those created under outlook)

    You browse WellKnownFolderName.Root with a filter, but before posting I used FindFolders method on root with FolderTraversal.Deep without any filter: it doesn't find them! (They have elements in them)

    I compared with Outlook Spy an EWS-made search folder & one made under Outlook and they have the same properties (except names, items count etc) They both have PR_FOLDER_TYPE = 2

    The FindFolders method just can't find the Outlook ones.

    So either I didn't create those folder with outlook the proper way (right click on search folder, create a new search folder and then even the basic, without custom criteria, for example Important emails (and yes, I have emails in it))

    Either it's something else, and I can't find out what :/

    Thx again Glen, I'm really stuck on this problem. 

    ps: I'm using Exchange 2010SP1, EWS1.1, Outlook 2010

    Wednesday, February 23, 2011 9:18 AM
  • Okay i just tried this and it works fine for me with the same versions and new search folder created in Outlook just using

          FolderView fv = new FolderView(1000);
          FindFoldersResults ffResults = service.FindFolders(WellKnownFolderName.SearchFolders, fv);
          foreach (Folder ff in ffResults) {

     If you use OutlookSpy and look in the finder folder can use see the search folder in there ?. Try to enable tracing when the search is being done and have a look at the request and results. Running the lastest rollups on the server ? Also are you doing any funny with permissions are you accessing the mailbox as the mailbox owner ?


    Thursday, February 24, 2011 2:19 AM
  • It still only retrieves EWS search folders.

    I installed the 2 rollups for Exchange 2010SP1.

    I checked with Outlook spy (under Finder) and yeah, search folders created with Outlook are there.

    I compared their properties and except for obvious ones (ie: name, date, entryID) and for pr_extended_folder_flags, PR_LONGTERM_ENTRYID_FROM_TABLE(=PR_RECORD_KEY and PR_SEARCH_KEY), they are the same.

    (Those previous differences also exist between 2 search folders made with EWS)

    I traced request and result with Wireshark, and everything's ok except for the missing elements in the result:


    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
     <t:RequestServerVersion Version="Exchange2010_SP1" />
     <m:FindFolder Traversal="Shallow">
      <m:IndexedPageFolderView MaxEntriesReturned="1000" Offset="0" BasePoint="Beginning" />
      <t:DistinguishedFolderId Id="searchfolders" />



    <?xml version="1.0" encoding="utf-8"?><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <h:ServerVersionInfo MajorVersion="14" MinorVersion="1" MajorBuildNumber="218" MinorBuildNumber="14"
     Version="Exchange2010_SP1" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types"
     xmlns="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
     <m:FindFolderResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" 
    		<m:FindFolderResponseMessage ResponseClass="Success">
    	 <m:RootFolder IndexedPagingOffset="2" TotalItemsInView="2" IncludesLastItemInRange="true">



    I don't think it's a permission problem, I mean it's a really simple setup: The client run on the same domain than the Exchange Server, and the email account is made for the AD account I use to run the client. Outlook is used under the same machine than the client. Plus, under Outlook I can create a custom folder in Inbox for example, and it'll be retrieved with EWS

    So if you tell me it works on your configuration, I guess there is a problem with my installation. I just can't find out where. Can't find this Exchange option checkbox:  "Let EWS retrieve search Folders made under outlook: Yes/No" 


    Thank you Glen


    Thursday, February 24, 2011 1:13 PM
  • This shouldn't really matter but are you using Outlook in Cache mode ? What happens if you switch it to online mode and create a simple search folder.


    • Marked as answer by RadigouTD Friday, February 25, 2011 9:18 AM
    Friday, February 25, 2011 2:31 AM
  • Thank you Glen, that was the problem. I realized I had an error when Outlook was trying to send/retrieve information to/from Exchange server (0x8004010F)

    Outlook was using cache mode (the default option). When I turned off this cache mode, I had my search folders disabled, clicking on it to enable them made them visible with EWS.

    Thank you very much again!

    Friday, February 25, 2011 9:21 AM