In a previous project where I used EWS, my search criteria was much simpler: find emails with "xxx" in the Subject.
I'm now building this code into a more multi-purpose application; I will be monitoring various mailboxes for various criteria, for example:
Find all mail items where the recipient is "email@example.com", AND subject contains "xxx" AND (body contains "yyy" OR body contains "zzz")
However, using a SearchFilterCollection, although I can add multiple SearchFilters, I don't see how to apply different logical operators... there seems to be one logical operator per SearchFilterCollection:
SearchFilterCollection sfc = new SearchFilterCollection(LogicalOperator.Or, new SearchFilter.ContainsSubstring(ItemSchema.Subject, "Test"));
I suppose one solution would be to find a superset of the desired mail items, and then filter them more accurately later, when they are being processed. But I was wondering if there is a better way of filtering at the start, using SearchFilters or any other means?
preguntado el 02 de febrero de 12 a las 11:02
You could build-up your complex Searchfilter using
SearchFilter.SearchFilterCollection (LogicalOperator, SearchFilter)