Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# vsto+;区分附件_C#_Outlook_Vsto_Outlook Addin - Fatal编程技术网

C# vsto+;区分附件

C# vsto+;区分附件,c#,outlook,vsto,outlook-addin,C#,Outlook,Vsto,Outlook Addin,我需要从邮件项目中获取并保存附件,但使用下面的代码会返回所有附件-这意味着它还会返回嵌入的图像,如发件人的带有徽标的签名(即图像)。如何区分真实附件与嵌入图像?我在论坛上看到了很多,但我仍然不清楚 public static void SaveData(MailItem currentMailItem) { if (currentMailItem != null) { if (currentMailItem.Attachments.Count >

我需要从邮件项目中获取并保存附件,但使用下面的代码会返回所有附件-这意味着它还会返回嵌入的图像,如发件人的带有徽标的签名(即图像)。如何区分真实附件与嵌入图像?我在论坛上看到了很多,但我仍然不清楚

public static void SaveData(MailItem currentMailItem)
{
    if (currentMailItem != null)
    {       
        if (currentMailItem.Attachments.Count > 0)
        {
            for (int i = 1; i <= currentMailItem.Attachments.Count; i++)
            {
                currentMailItem.Attachments[i].SaveAsFile(@"C:\TestFileSave\" + currentMailItem.Attachments[i].FileName);
            }
        }
    }   
}
publicstaticvoidsavedata(mailitemcurrentmailitem)
{
如果(currentMailItem!=null)
{       
如果(currentMailItem.Attachments.Count>0)
{

对于(int i=1;i,您可以使用以下命令检查附件是否是内联的

您可以使用访问消息正文格式,也可以使用访问MIME附件属性

string PR\u ATTACH\u方法http://schemas.microsoft.com/mapi/proptag/0x37050003';
var attachMethod=attachment.PropertyAccessor.Get(PR_ATTACH_方法);
字符串PR_ATTACH_FLAGS='1〕http://schemas.microsoft.com/mapi/proptag/0x37140003';
var attachFlags=attachment.PropertyAccessor.Get(PR_ATTACH_标志);
if body format is plain text then
   no attachment is inline
else if body format is RTF then
   if PR_ATTACH_METHOD value is 6 (ATTACH_OLE) then
     attachment is inline
   else
     attachment is normal
else if body format is HTML then
   if PR_ATTACH_FLAGS value has the 4 bit set (ATT_MHTML_REF) then
     attachment is inline
   else
     attachment is normal