Folder.Bind
Allow you to bind the folder that you want. You can even bind to the folder of other user if you have permission. Or whatever folder once you recover the FolderID (you can use it as a parameter)
For example, If I am an exchange administrator and I would like to get the Root Folder of a user who has the smtp address "[email protected]", I would bind to the folder this way:
Folder FolderBind =
Folder.Bind(service, new FolderId
(WellKnownFolderName.MsgFolderRoot, "[email protected]));
Once you have the FolderBind loaded with whatever folder you want, you can use the other method, because it receives the Folder.ID
parameter that you may not know. But know thanks to Folder.Bind, you have the FolderID of the MsgFolderRoot
of "[email protected]", so you can perform a search inside his items with:
FindItemsResults<Item> findResults = service.FindItems(FolderBind.Id, searchFilter, view);
I don't know If I made myself clear. I you have more doubts just ask.
EDIT:
You can give to the FindItems a refinated searchFilter that will allow you to get items
attending to some requirements. Like searching emails with attachment. Searching emails
older than some date. ett.
Here an example:
List<SearchFilter> searchORFilterCollection = new List<SearchFilter>();
searchORFilterCollection.Add( new SearchFilter.IsEqualTo(EmailMessageSchema.HasAttachments, true));
searchORFilterCollection.Add(new SearchFilter.IsLessThan(EmailMessageSchema.DateTimeReceived,DateTime.Now.AddMonths(-3)));
SearchFilter searchFilter= new SearchFilter.SearchFilterCollection(LogicalOperator.And,searchORFilterCollection.ToArray());