Mobile Line Of Business

Richard Jones (MVP)

  Home  |   Contact  |   Syndication    |   Login
  202 Posts | 0 Stories | 36 Comments | 0 Trackbacks


Welcome to the Mobile Line Of Business Blog

Tag Cloud


Post Categories


I’ve been building a room booking system and I needed a mobile client to be able to book rooms/resources.

As our room bookings are all stored in Exchange Public folders,  I thought I would take Exchange Web-Services (EWS) for a spin.

If you have Exchange 2007,  you should find EWS installed.   I just added a web-reference to


Here’s a function that enumerates all public folders.

I’m skipping some of the initial connection details, but it really is very straight forward.



private Hashtable getfolders(ExchangeServiceBinding ews, BaseFolderIdType folderid)

       Hashtable ht = new Hashtable();
       FindFolderType request = new FindFolderType();
       request.Traversal = FolderQueryTraversalType.Shallow;
       request.FolderShape = new FolderResponseShapeType();
       request.FolderShape.BaseShape = DefaultShapeNamesType.AllProperties;
       request.ParentFolderIds = new BaseFolderIdType[] { folderid };
       FindFolderResponseType response = ews.FindFolder(request);

       foreach (ResponseMessageType rmt in response.ResponseMessages.Items)
           if (rmt.ResponseClass == ResponseClassType.Success)
               FindFolderResponseMessageType ffResponse = (FindFolderResponseMessageType)rmt;
               if (ffResponse.RootFolder.TotalItemsInView > 0)
                   foreach (BaseFolderType subFolder in ffResponse.RootFolder.Folders)
                       ht.Add(subFolder.FolderId.Id, subFolder.DisplayName);
                       Hashtable subs = getfolders(ews, subFolder.FolderId);
                       foreach (string key in subs.Keys)
                           ht.Add(key, subs[key]);

       return ht;

posted on Tuesday, December 1, 2009 11:25 AM