【发布时间】:2014-04-15 00:09:01
【问题描述】:
我正在尝试阅读特定的电子邮件帐户,以查找带有未读附件且主题中有特定字词的项目。
我有以下代码有效,但只读取我的收件箱,不是我要检查的收件箱
static void Main(string[] args)
{
ServicePointManager.ServerCertificateValidationCallback=CertificateValidationCallBack;
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);// .Exchange2007_SP1);
service.UseDefaultCredentials = true;
service.AutodiscoverUrl("bbtest@domainname.com"); //, RedirectionUrlValidationCallback); //bbtest@bocuk.local
ItemView view = new ItemView(1);
string querystring = "HasAttachments:true Kind:email";
//From:'Philip Livingstone' Subject:'ATTACHMENT TEST' Kind:email";
// 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, querystring, view);
foreach (EmailMessage email in results)
if (email.IsRead == false) // && email.HasAttachments == true
{
System.Diagnostics.Debug.Write("Found attachemnt on msg with subject: " + email.Subject);
// Request all the attachments on the email message.
//This results in a GetItem operation call to EWS.
email.Load(new PropertySet(EmailMessageSchema.Attachments));
foreach (Attachment attachment in email.Attachments)
{
if (attachment is FileAttachment)
...
我需要进行哪些更改才能让我的代码读取 bbtest@domainname.com 收件箱中的消息?
【问题讨论】:
-
@JakobChristensen : - 我认为你是对的......我现在遇到了一个错误问题 在商店中找不到指定的对象。
-
哪行代码给你这个错误?
-
@JakobChristensen:这会受到我的测试电子邮件帐户被隐藏的影响吗?
-
也许吧。您是否在自动发现期间或调用 FindItems 时收到错误?
-
它是在 FindItems 期间,但我已将其取消隐藏,我将使用网络凭据来确保我可以读取目标邮箱。
标签: c# soap exchangewebservices exchange-server-2010