使用SearchFilterCollection通过电子邮件地址搜索Exchange邮箱 [英] searching Exchange mailbox by email address using SearchFilterCollection
本文介绍了使用SearchFilterCollection通过电子邮件地址搜索Exchange邮箱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Exchange Web服务搜索电子邮件收件箱(在Exchange 2010上).
I am searching an email inbox (on Exchange 2010) using Exchange Web Services.
在我的SearchFilterCollection中,我想包含电子邮件的From.Address
属性,因为我只想检索包含特定域(例如@ domain.co.uk)的电子邮件
In my SearchFilterCollection I would like to include the From.Address
property of the Email message, as I only want to retrieve emails that include a certain domain (such as @domain.co.uk)
这是我的代码:
SearchFilter.SearchFilterCollection searchFilterCollection = new SearchFilter.SearchFilterCollection(LogicalOperator.And);
searchFilterCollection.Add(new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, false));
searchFilterCollection.Add(new SearchFilter.IsEqualTo(EmailMessageSchema.HasAttachments, true));
// **** PROBLEM HERE ON BELOW LINE****
searchFilterCollection.Add(new SearchFilter.ContainsSubstring(EmailMessageSchema.From, "@domain.co.uk")); //
// add the exceptions
for (int iEx = 0; iEx < e2c.emailExceptions.Count; iEx++)
{
searchFilterCollection.Add(new SearchFilter.Not(new SearchFilter.ContainsSubstring(EmailMessageSchema.Subject, e2c.emailExceptions[iEx])));
}
ItemView view = new ItemView(100);
view.OrderBy.Add(ItemSchema.DateTimeReceived, SortDirection.Ascending);
// Find the first email message in the Inbox that has attachments. This results in a FindItem operation call to EWS.
FindItemsResults<Item> results = service.FindItems(WellKnownFolderName.Inbox, searchFilterCollection, view);
是否有一种在SearchFilter中包含电子邮件地址的好方法?
is there a good way to include the email address in the SearchFilter?
推荐答案
查看全文