【发布时间】:2017-01-30 06:37:06
【问题描述】:
我创建了一个小型应用程序来接收我的所有电子邮件。我将每封电子邮件添加到列表中。但是,在将它们添加到列表之前,我会过滤它们。我所有的过滤器都在除一个之外工作。我用于按发件人过滤我的电子邮件的搜索过滤器不起作用,因为我只是试图过滤域而不是整个电子邮件地址。例如 xxx@xxx.com 将过滤,但是我想过滤掉 xxx.com 域的所有内容,并且由于某种原因它不会过滤它。我尝试使用子字符串,这也不起作用。
我的代码是休闲的
private static SearchFilter.SearchFilterCollection sFilter = new SearchFilter.SearchFilterCollection();
private static FindItemsResults<Item> findResults;
sFilter.Add(new SearchFilter.Not(new SearchFilter.ContainsSubstring(EmailMessageSchema.Sender, "@xxx.com",ContainmentMode.Substring,ComparisonMode.IgnoreCase)));
sFilter.Add(new SearchFilter.Not(new SearchFilter.Exists(EmailMessageSchema.InReplyTo)));
DateTime startTime = GetDateValueforFilter();
startTimefilter = new SearchFilter.IsGreaterThanOrEqualTo(EmailMessageSchema.DateTimeReceived, startTime);
sFilter.Add(startTimefilter);
sFilter.Add(startTimefilter);
findResults = service.FindItems(
WellKnownFolderName.Inbox
,sFilter
,new ItemView(25));
foreach (EmailMessage item in findResults.Items)
{
//if (item.IsRead == false)
//{
// if (item.InReplyTo == null)
// {
bool replyToAll = true;
string myReply = "This is the message body of the email reply.";
item.Reply(myReply, replyToAll);
item.IsRead = true;
item.Send();
//}
//}
}
【问题讨论】:
-
我不想使用特定的电子邮件地址,我只想要电子邮件的域,例如 xxx.com 而不是 xxx@xxx.com。您提供的示例只会过滤一个确切的电子邮件地址
-
是的,我明白了,也请阅读 cmets,他们可能会提供帮助。
标签: c# email exchangewebservices