-->

Exchange Web Service (EWS) FindItems does not find

2019-07-23 06:49发布

问题:

I'm using SearchFolder to do a deep traversal search on an EWS connected to Office365. The problem is that I don't get all the matching email results when using FindItems for this folder. I don't get emails with HTML body that contains "text" (for Text body it work). But when I using FindItems for a normal folder it return all emails.

var subjectFilter = new SearchFilter.ContainsSubstring(ItemSchema.Subject, text, ContainmentMode.Substring, ComparisonMode.IgnoreCase);
var bodyFilter = new SearchFilter.ContainsSubstring(ItemSchema.Body, text, ContainmentMode.Substring, ComparisonMode.IgnoreCase);
var searchFilter = new SearchFilter.SearchFilterCollection(LogicalOperator.Or, subjectFilter, bodyFilter);
var findItems = service.FindItems(searchFolderID, searchFilter, view);

回答1:

You can not include Body property in FindItems request. You need to browse the list of mails, then you load the Body property. See: https://stackoverflow.com/a/25840741/1364448