Pregunta

My goal is to create a custom SearchFilter for EWS. I would like for example to search all emails subject with a custom algorithm (Soundex for example or something 'home made').

I would like to be able to do something like this:

SearchFilter.SearchFilterCollection filter = new SearchFilter.SearchFilterCollection(LogicalOperator.And);
filter.Add(new SearchFilter.ContainsSubstring(ItemSchema.Categories, myCategory)) // Standard .NET Filter
filter.Add(new MyFilter(ItemSchema.XXXX, myVariable)) // <-- A custom implementation

The SearchFilter class is public but has an internal constructor which prevent me to derive the class. Predefined search classes like ContainsSubstring or IsLessThan are sealed (and derive from SearchFilter).

Does anybody see a solution !?

¿Fue útil?

Solución

Unfortunately this isn't possible. The SearchFilter classes in the EWS Managed API ultimately have to serialize into SOAP XML that conforms to the Exchange Web Services schema. For example, a SearchFilter.ContainsSubstring serializes into a Contains XML element in the SOAP request. You can see examples of all of the Managed API classes and equivalent SOAP here: http://msdn.microsoft.com/EN-US/library/office/dn579422(v=exchg.150).aspx.

So in order to send a filter via SOAP, it has to conform to the schema, which means it has to be one of the available filter types. There's no way to send a custom type. In order to do custom filter processing, you would need to pull the relevant data down to your client, and do the filtering there.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top