當然,這並不是一件緊迫的事情,但我想我會分享任何在未來會像我一樣磕磕絆絆的人。
對於您需要加載MimeContent該項目ItemAttachments,那麼你可以簡單地寫在文件/輸出[「的.eml」,「味精」]:
if (attachment is FileAttachment)
{
FileAttachment fileAttachment = attachment as FileAttachment;
// Load attachment contents into a file.
fileAttachment.Load(<file path>);
}
else // Attachment is an ItemAttachment (Email)
{
ItemAttachment itemAttachment = attachment as ItemAttachment;
// Load Item with additionalProperties of MimeContent
itemAttachment.Load(EmailMessageSchema.MimeContent);
// MimeContent.Content will give you the byte[] for the ItemAttachment
// Now all you have to do is write the byte[] to a file
File.WriteAllBytes(<file path>, itemAttachment.Item.MimeContent.Content);
}
什麼Microsoft.Exchange版本.WebServices.dll你使用? –