簡體   English   中英

C# EWS O365 使用帶有或的 Searchfilter 獲取 eMail

[英]C# EWS O365 Get eMail using Searchfilter with or

我想搜索郵件並有幾個過濾器。 據我所知,所有過濾器都使用“和”連接,因此所有過濾器都必須有效。 有什么東西可以使用帶“或”的過濾器嗎?

searchFilterCollection.Add(new SearchFilter.ContainsSubstring(ItemSchema.Subject, "Test"));
searchFilterCollection.Add(new SearchFilter.ContainsSubstring(ItemSchema.Body, "socks"));
searchFilterCollection.Add(new SearchFilter.ContainsSubstring(EmailMessageSchema.Sender, "yyy@yyy.com"));

或者

searchFilterCollection.Add(new SearchFilter.ContainsSubstring(ItemSchema.Subject, "Test"));
searchFilterCollection.Add(new SearchFilter.ContainsSubstring(ItemSchema.Body, "socks"));
searchFilterCollection.Add(new SearchFilter.ContainsSubstring(EmailMessageSchema.Sender, "zzz@zzz.com"));

我必須開始兩個不同的搜索還是有類似的東西

(
 ( filter1 ) and
 ( filter2 ) and
 ( ( filter3a ) or ( filter3b ) )
)

我讀了 learn.microsoft.com https://learn.microsoft.com/de-de/exchange/client-developer/exchange-web-services/how-to-use-search-filters-with-ews-in-exchange ?msclkid=a2ee168fab7711ec971951bfdcbc8e44

但我找不到答案。

到目前為止,我只嘗試了不止一次搜索來獲取郵件。 一個“或”的結果還可以,但如果有多個“或”,您就會迷失在代碼中。

您可以嵌套 SearchFilter collections 所以在您的示例中

( ( filter3a ) 或 ( filter3b ) )

將是一個 SearchFilterCollection 實現或者只有當兩個 Or 過濾器之一為真時才會實現 And ,例如制作它或者你只是使用構造函數來實現

SearchFilter.SearchFilterCollection nestedSearchFilterCollection =
new SearchFilter.SearchFilterCollection(LogicalOperator.Or);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM