使用SearchFilterCollection通过电子邮件地址搜索Exchange邮箱 [英] searching Exchange mailbox by email address using SearchFilterCollection

查看:330
本文介绍了使用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?

推荐答案

前几天,我使用

现在,这是使用Sender属性,而不是From属性.我认为您可以简单地将一个替换为另一个,但是我没有进行测试来确定.

Now this is using the Sender property, not the From property. I think you could simply replace one for the other, but I didn't test to be sure.

这篇关于使用SearchFilterCollection通过电子邮件地址搜索Exchange邮箱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆