Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exchange Web Services: More Complex SearchFilters

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 protected]", 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?

like image 576
CJM Avatar asked Feb 02 '12 11:02

CJM


1 Answers

You could build-up your complex Searchfilter using SearchFilter.SearchFilterCollection (LogicalOperator, SearchFilter[])

Check: HOW TO: Build a complex search using SearchFilter and SearchFilterCollection in EWS Managed API 1.0

like image 109
Bolu Avatar answered Sep 22 '22 01:09

Bolu