Exchange Web服务(EWS)自定义筛选器

时间:2014-03-28 17:43:01

标签: c# .net search filter exchangewebservices

我的目标是为EWS创建自定义SearchFilter。我想举例来搜索所有使用自定义算法的电子邮件(例如Soundex或者自制的')。

我希望能够做到这样的事情:

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

SearchFilter类是公共的,但有一个内部构造函数,阻止我派生类。 ContainsSubstringIsLessThan等预定义搜索类是密封的(并且来自SearchFilter)。

有人看到了解决方案吗??

1 个答案:

答案 0 :(得分:2)

不幸的是,这是不可能的。 EWS托管API中的SearchFilter类最终必须序列化为符合Exchange Web服务架构的SOAP XML。例如,SearchFilter.ContainsSubstring序列化为SOAP请求中的Contains XML元素。您可以在此处查看所有托管API类和等效SOAP的示例:http://msdn.microsoft.com/EN-US/library/office/dn579422(v=exchg.150).aspx

因此,为了通过SOAP发送过滤器,它必须符合模式,这意味着它必须是可用的过滤器类型之一。没有办法发送自定义类型。要进行自定义过滤处理,您需要将相关数据提取到客户端,并在那里进行过滤。