我对EWS有一个奇怪的问题。我正在编写一个控制台应用程序,用于在我的收件箱中查询包含' Ref:'这绝对没问题,我得到连接没问题,运行查询,得到一些结果。但奇怪的是,它只返回来自内部发件人的邮件,从交换机构外部发送的任何邮件都不会出现在结果中。
最终我将使用服务帐户连接到各种邮箱,并找到包含该主题中某些引用的各种电子邮件....
有没有人知道可能会发生什么?我已经过去了,并且找不到它为什么要这样做。
它的Exchange 2010 SP2
ExchangeService exchService = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
exchService.Url = new System.Uri("https://xxx.xxxxxxxxx.co.uk/EWS/Exchange.asmx");
exchService.UseDefaultCredentials = true;
var userMailbox = new Mailbox("xxxx@xxxx.co.uk");
var inboxFolder = new FolderId(WellKnownFolderName.Inbox, userMailbox);
String qString = "subject:\"Ref:\"";
ItemView view = new ItemView(20);
view.PropertySet = new PropertySet(ItemSchema.Id);
try
{
FindItemsResults<Item> results = exchService.FindItems(inboxFolder, qString, view);
if (results.Items.Count > 0)
{
foreach (Item item in results.Items)
{
Console.WriteLine(item.Id);
if (item is EmailMessage)
{
EmailMessage bindMessage = EmailMessage.Bind(exchService, item.Id.ToString());
String sender = bindMessage.Sender.Address.ToString();
String Body = bindMessage.Body.Text.ToString();
Console.WriteLine("Sender: " + sender);
}
}
}
}