【发布时间】:2020-05-12 07:47:11
【问题描述】:
对不起,如果我的帖子是重复的,我试图找到解决方案但没有成功。 我需要阅读 Office365 电子邮件文件夹并获取每封邮件中包含的附件。 我用这个代码
foreach (Attachment attachment in message.Attachments)
{
if (attachment is FileAttachment)
{
FileAttachment fileAttachment = attachment as FileAttachment;
// Load the attachment into a file.
// This call results in a GetAttachment call to EWS.
fileAttachment.Load("C:\\temp\\" + fileAttachment.Name);
Console.WriteLine("File attachment name: " + fileAttachment.Name);
}
else // Attachment is an item attachment.
{
ItemAttachment itemAttachment = attachment as ItemAttachment;
// Load attachment into memory and write out the subject.
// This does not save the file like it does with a file attachment.
// This call results in a GetAttachment call to EWS.
itemAttachment.Load();
Console.WriteLine("Item attachment name: " + itemAttachment.Name);
}
}
取自这里link 来执行此操作。 但是,发件人发送的“真实”附件(pdf 文件、xls 或图像)一起,代码会下载每封邮件中包含的所有元素,即徽标、html 正文中的图像等。 有没有办法只选择“真实”附件并避免下载标志和正文中包含的其他 html 元素? 谢谢你的帮助。 卢修斯
【问题讨论】:
标签: c# exchangewebservices email-attachments