当然,这仍然不是一个紧迫的问题,但我想我会和我一样在未来偶然发现这个问题的人分享。
对于 ItemAttachments,您需要为该项目加载 MimeContent,然后您可以简单地写入文件/输出 [".eml", ".msg"]:
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);
}