我正在使用 EWS 1.2 在我的邮箱中搜索带有附件的电子邮件,并将 EmailMessage 对象绑定到 EWS 对象。这工作正常,但没有检测到 .msg 文件(outlook 消息文件):
ItemView mailview = new ItemView (12);
FindItemsResults<Item> resultmail;
resultmail = Service.FindItems(WellKnownFolderName.Inbox, mailview);
foreach (Item item in resultmail.Items)
{
EmailMessage email = EmailMessage.Bind(Service, item.Id,
new PropertySet(BasePropertySet.FirstClassProperties,
ItemSchema.Attachments));
if (email.HasAttachments)
{
foreach (var attachment in email.Attachments)
{
if (attachment is FileAttachment)
{
Console.WriteLine("email has : " + email.Attachments.Count
+ "attachement(s)" + "\n");
Console.WriteLine("attachment name:" + attachment.Name);
}
}
}
}