本文介绍了如果附件是邮件,如何访问附件数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

全部,


我以下列方式以编程方式获取附件数据: -


Microsoft.Office.Interop。 Outlook.Attachment attachment = objMail.Attachments [attachmentIndex];


if(attachment.DisplayName.Equals(" Test"))


{  ;


    const string PR_ATTACH_DATA =" http://schemas.microsoft.com/mapi/proptag/0x37010102" ;;


    byte [] attachmentData = attachment.PropertyAccessor.GetProperty(PR_ATTACH_DATA);


}


现在我的代码工作正常,如果附件是文本文件或图像文件。但是如果附件本身就是一个邮件,它会抛出属性未知或无法找到的异常。


请建议在哪种情况下/附件类型,此属性"http:/ /schemas.microsoft.com/mapi/proptag/0x37010102"将无法工作,在这种情况下,什么是替换属性/方法来获取字节数组中的附件数据?


谢谢


Devendra

解决方案

HI All,

I am programmatically getting the attachment data in following way :--

Microsoft.Office.Interop.Outlook.Attachment attachment = objMail.Attachments[attachmentIndex];

if (attachment.DisplayName.Equals("Test"))

   const string PR_ATTACH_DATA = "http://schemas.microsoft.com/mapi/proptag/0x37010102";

    byte[] attachmentData = attachment.PropertyAccessor.GetProperty(PR_ATTACH_DATA);

}

Now my code is working fine if attachment is text file or image file. But if attachment is itself a mail, it throws the exception that property is unknown or can not be found.

Please suggest in which cases / type of attachments, this property "http://schemas.microsoft.com/mapi/proptag/0x37010102" will not work and in those case what would be alternative property / method to get the attachment data in byte array ?

Thanks

Devendra

解决方案


这篇关于如果附件是邮件,如何访问附件数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 07:16