【发布时间】:2014-04-10 15:00:51
【问题描述】:
我正在使用 Exchange Web 服务搜索电子邮件收件箱(在 Exchange 2010 上)。
在我的 SearchFilterCollection 中,我想包含电子邮件的 From.Address 属性,因为我只想检索包含特定域(例如 @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 中包含电子邮件地址的好方法?
【问题讨论】:
标签: exchangewebservices exchange-server-2010 searchfiltercollection