I have a folder in an Exchange mailbox that is a child of the root (not Inbox).
How do I get the ID of such folder using EWS Managed API?
Only examples I
A bit late, but the following is what I used to find my folder:
var view = new FolderView(1);
view.Traversal = FolderTraversal.Deep;
var filter = new SearchFilter.IsEqualTo(FolderSchema.DisplayName, "Rejected");
var results = Service.FindFolders(WellKnownFolderName.Root, filter, view);
if (results.TotalCount < 1)
throw new Exception("Cannot find Rejected folder");
if (results.TotalCount > 1)
throw new Exception("Multiple Rejected folders");
Rejected = Folder.Bind(Service, results.Folders.Single().Id);
Edit: Apparently my code did not work on nested heirarchies. I added a line as per cookiemonster's suggested edit.