如果附件是邮件,如何访问附件数据 [英] How to access attachment data if attachment is mail

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

问题描述

全部,


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


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全部,


正如Dmitry所回答的那样,可以使用IAttach.OpenProperty来实现。有人可以提供示例,如何调用此函数在C#中打开任何嵌入的附件。


谢谢


Dev


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

解决方案

HI All,

As replied by Dmitry, it can be achieved using IAttach.OpenProperty. Can someone please provide the example, how can I call this function to open any embedded attachment in C#.

Thanks

Dev


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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆