在VSTO C#中获取RTF邮件的附件内容
我们正在尝试获取RTF邮件中附件的内容,但我尝试使用不同的术语搜索,但没有找到任何可靠的解决方案。有人可以帮助我以HTML格式获得附件的来源。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
我们正在尝试获取RTF邮件中附件的内容,但我尝试使用不同的术语搜索,但没有找到任何可靠的解决方案。有人可以帮助我以HTML格式获得附件的来源。
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(3)
Outlook对象模型不提供任何获取附件内容的属性或方法。要连接文件,您需要将其保存到磁盘上,然后从那里读取内容。
另外,您可以考虑使用Outlook基于扩展MAPI的低级API。它允许获取所附文件的二进制数据。尝试使用
attactment.propertyaccessor.getProperty
方法传递“ http://schemas.microsoft.com/mapi/mapi/mapi/proptag/0x37010102”(pr_attach_data_data_bin
)。The Outlook object model doesn't provide any property or method for getting the attachment content. To get the file attached you need to save it to the disk and then read the content from the there.
Also you may consider using a low-level API on which Outlook is based on - Extended MAPI. It allows getting the binary data of the attached file. Try using the
Attachment.PropertyAccessor.GetProperty
method while passing in the value "http://schemas.microsoft.com/mapi/proptag/0x37010102" (PR_ATTACH_DATA_BIN
).在低级别(C ++或Delphi中的扩展MAPI)上,您需要打开
pr_attach_data_obj
属性为istorage
并从那里提取数据(这取决于实际类型附件)。您可以在 iMessage OutlookSpy色带上的按钮,转到getAttachmentTable
TAB,双击附件上的附件,选择pr_attach_data_obj
属性,右键单击,选择imapiprop :: OpenProperty
,然后istorage
。原始数据以及代表附件的图像将存在(因此Outlook在渲染消息时不必启动主机应用程序)。如果使用 rexemption 是一个选项(我也是它的作者,可以从任何语言中使用,包括任何语言c#and vba),其版本的 rdoattachment 。方法处理大多数流行格式的OLE附件(Word,Excel,Bitmap,Power Point,Adobe PDF等) - 创建一个 rdosession 对象(使用
crealeoleobject
或 redemptivemtionloader )并使用rdosession.getRdoObject fromoutlookObject
方法(通过mailItem
或或附件
附件对象) rdomail 或 rdoattachment 对象。On the low level (Extended MAPI in C++ or Delphi), you need to open the
PR_ATTACH_DATA_OBJ
property asIStorage
and extract the data from there (it depends on the actual type of the attachment). You can see the data in the streams in OutlookSpy (I am its author) - select the message, clickIMessage
button on the OutlookSpy ribbon, go to theGetAttachmentTable
tab, double click on the attachment to open it, select thePR_ATTACH_DATA_OBJ
property, right click, selectIMAPIProp::OpenProperty
, thenIStorage
. Raw data will be there as well as an image representing the attachment (so that Outlook won't have to start the host app when rendering the message).If using Redemption is an option (I am also its author, it can be used from any language including C# and VBA), its version of RDOAttachment.
SaveAsFile
method handles OLE attachments for most popular formats (Word, Excel, bitmap, Power Point, Adobe PDF, etc.) - create an instance of the RDOSession object (using eitherCrealeOleObject
or RedemptionLoader) and useRDOSession.GetRDOObjectFromOutlookObject
method (pass eitherMailItem
orAttachment
object) to get back RDOMail or RDOAttachment object respectively.我发现了一种解决方案,可以直接从RTF邮件中获取图像内容,直接击中低级API或其他任何内容。
该解决方案不是直接的,
现在阅读.htm doc
i have been found a solution for getting the images content from the rtf mail directly whiteout hitting the low level api or anything.
the solution is not a straight forward one
now read the .htm doc