如何区分 Outlook 电子邮件附件和 C# 中的嵌入图像?

问题描述 投票:0回答:0

我正在开发 Outlook VSTO 项目,我必须将电子邮件的所有附件保存到特定文件夹。我正在循环浏览附件并检查它们的类型,如下所示:

Outlook.Inspector currentInspector = outlookApp.ActiveInspector();
var selectedMail = currentInspector.CurrentItem as Outlook.MailItem;

foreach (Outlook.Attachment attachment in selectedMail.Attachments)
{
    var attachmentType = attachment.Type; // this is "olByValue" all the time -- in case of embedded images, as well as actual attachments
}

(selectedMail.Attachments 包含实际附件,以及电子邮件正文中嵌入/粘贴的图片)。

这里有办法区分附件和嵌入图像吗?

现在我用来过滤嵌入图像的方法是检查文件是否小于 20KB 并且是图像,将其排除。但这并不完美,就好像有人实际上将小于 20KB 的图像附加到电子邮件中一样,这会将其排除在外。

c# vsto outlook-addin
© www.soinside.com 2019 - 2024. All rights reserved.