本文介绍了Exchange Web服务:查找发送给收件人的电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Exchange Web Services连接到邮箱,并使用查找项,带有 SearchFilter .

I'm using Exchange Web Services to connect to a mailbox and look for messages matching certain criteria, using FindItems with a SearchFilter.

我可以这样在邮箱中过滤发件人"电子邮件地址中的电子邮件:

I can get emails in a mailbox filtering on 'from' email address like this:

var service = new ExchangeService(ExchangeVersion.Exchange2010_SP1)
            {
                TraceEnabled = true,
                Credentials = new WebCredentials(username, password)
            };

var filter = new SearchFilter.ContainsSubstring(EmailMessageSchema.From, "[email protected]");

service.FindItems(WellKnownFolderName.Inbox, filter, new ItemView(50))

我可以像这样过滤DisplayTo属性:

And I can filter on the DisplayTo property like this:

var filter = new SearchFilter.ContainsSubstring(EmailMessageSchema.DisplayTo, "display name");

但据我所知,它仅搜索收件人的显示名称.我想搜索一个电子邮件地址或域名.

But as far as I can tell that only searches the recipient's display name. I want to search on an email address or domain name.

当我期望它不会返回结果时

This doesn't return results when I would expect it to:

var filter = new SearchFilter.ContainsSubstring(EmailMessageSchema.ToRecipients, "[email protected]");

是否可以找到收件人列表中包含指定电子邮件地址的所有电子邮件?

推荐答案

我没有找到使用SearchFilter根据收件人电子邮件地址查找电子邮件的方法.

I didn't find a way to use a SearchFilter to find emails based on recipient email address.

可以使用不同的ExchangeService.FindItems重载来获取查询字符串.

It is possible using a different overload of ExchangeService.FindItems which takes a querystring.

查找在收件人"或抄送"字段中地址的电子邮件

var contactEmailAddress = "[email protected]";

var querystring = string.Format("Participants:={0}", contactEmailAddress);

service.FindItems(WellKnownFolderName.Inbox, queryString, view);

查找在发件人",收件人"或抄送"字段中地址的电子邮件

var contactEmailAddress = "[email protected]";

var querystring = string.Format("(From:={0} OR Participants:={0})", contactEmailAddress);

service.FindItems(WellKnownFolderName.Inbox, queryString, view);

我认为此功能需要Exchange 2010.

I think this feature requires Exchange 2010.

有关查询语法的一些其他资源:

Some additional resources on query syntax:

  • QueryString (QueryStringType) [MSDN]
  • Using Exchange Search and AQS with EWS on Exchange 2010

这篇关于Exchange Web服务:查找发送给收件人的电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 19:09