Reputation: 1139
I want to retrieve email folders from OWA using EWS API (see screenshot below)
Here's my code:
FolderView folderView = new FolderView(MAX_VALUE);
FindFoldersResults findFoldersResults = service.findFolders(WellKnownFolderName.MsgFolderRoot, folderView);
The returned result contains all types of folders: appointment, email, messages, contacts, etc.
Calendar
Contacts
{06967759-274D-40B2-A3EB-D7F9E73727D7}
{A9E2BC46-B3A0-4243-B315-60D991004455}
Recipient Cache
Conversation Action Settings
custom folder
Deleted Items
Drafts
Inbox
Journal
Junk Email
Notes
Outbox
Sent Items
Tasks
How can I retrieve only email folders?
Upvotes: 0
Views: 1247
Reputation: 22032
You can filter out the hidden folders using a SearchFilter like
ExtendedPropertyDefinition isHiddenProp = new ExtendedPropertyDefinition(0x10f4, MapiPropertyType.Boolean);
FindFoldersResults findFolder = service.FindFolders(WellKnownFolderName.MsgFolderRoot,
new SearchFilter.IsEqualTo(isHiddenProp, false), folderView);
You could also filter out the Non Mail folder like contacts,calendar etc by filtering on FolderClass (eg use IPF.Note for mailbox folders). But its probably eaiser just to filter those at the client by checking the type when they are returned.
Upvotes: 2
Reputation: 1
Try to use WellKnownFolderName.Inbox
. Then you will retrieve only subfolders from your Inbox folder.
FindFoldersResults findFoldersResults = service.findFolders(WellKnownFolderName.Inbox, folderView);
Upvotes: 0