rusvid
rusvid

Reputation: 1

EWS: the simplest way to enumerate folders and to determine wellknown folders from them

I use the following code to enumerate folders:

FolderView view = new FolderView(100);
view.PropertySet = new PropertySet(BasePropertySet.FirstClassProperties);
view.PropertySet.Add(FolderSchema.DisplayName);
view.PropertySet.Add(FolderSchema.FolderClass);
FindFoldersResults results = service.FindFolders(WellKnownFolderName.MsgFolderRoot, view);
foreach (Folder folder in results.Folders)
{
    if (folder.Id.FolderName != null)
    {
       MessageBox.Show("WellknowFolder is found");
    }
}

Unfortunately, message box is never shown. For all folders FolderName(in property Id) is null. Even the folder is well-known folder like Contacts, Calendars and so on. Id contains only UniqueId. What is the simplest way to enumerate folders and to determine wellknown folders from them? Thank you.

Upvotes: 0

Views: 493

Answers (1)

Glen Scales
Glen Scales

Reputation: 22032

You need to include the FolderSchema.WellKnownFolderName property http://msdn.microsoft.com/en-us/library/microsoft.exchange.webservices.data.folderschema.wellknownfoldername(v=exchg.80).aspx in your property set eg

view.PropertySet.Add(FolderSchema.WellKnownFolderName);

As documented this will only work in Exchange 2013

Cheers Glen

Upvotes: 1

Related Questions