2014-03-28 104 views
0

我的目標是爲EWS創建自定義SearchFilter。我想例如搜索所有使用自定義算法的郵件主題(例如Soundex或「自制的」)。Exchange Web Service(EWS)自定義篩選器

我希望能夠做這樣的事情:

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派生)。

有沒有人看到解決方案!?

回答

2

不幸的是,這是不可能的。 EWS託管API中的SearchFilter類最終必須序列化爲符合Exchange Web Services架構的SOAP XML。例如,SearchFilter.ContainsSubstring序列化爲SOAP請求中的Contains XML元素。您可以在此查看所有託管API類和等效SOAP的示例:http://msdn.microsoft.com/EN-US/library/office/dn579422(v=exchg.150).aspx

所以爲了通過SOAP發送過濾器,它必須符合模式,這意味着它必須是可用的過濾器類型之一。無法發送自定義類型。爲了執行自定義過濾器處理,您需要將相關數據下載到您的客戶端,並在那裏進行過濾。