如何使用 MAPI 分离内联图像和附件?
我的程序使用 MAPI 来处理 Exchange 邮箱。问题是,如果用户启动 Outlook,添加一个文件作为附件,同时打开“画图”,选择其中的一个区域,将其复制到剪贴板并将其粘贴到邮件正文中,则生成的邮件将显示两个附件。
更具体地说,程序调用 IMAPIMessage::GetAttachmentsTable()
来检索附件表,并且该表包含两个对象。有没有一种方法可以让程序确定“附件”是否真的是附加文件或内联内容的一部分?
My program uses MAPI for working with Exchange mailboxes. The problem is if a user fires up Outlook, adds a file as an attachment and also opens Paint, selects a region there, copies it into clipboard and pastes into the message body the resulting message showns two attachments.
More specifically, the program calls IMAPIMessage::GetAttachmentsTable()
to retrieve the attachments table and that table contains two objects. Is there a way a program can decide whether the "attachment" is really an attached file or a portion of inline content?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要通过 img:cid 和 PT_ATTACH_CONENTS_ID 属性或通过文件名 (PR_ATTACH_LONG_FILENAME) 或内容位置 (PR_ATTACH_COMTENT_LOCATION) 检查 HTML 正文(通过 img 标记)是否引用附件。
You will need to check whether the HTML body (through the img tag) refers to the attachment, either through img:cid and PT_ATTACH_CONENTS_ID property or though the file name (PR_ATTACH_LONG_FILENAME) or contnet location (PR_ATTACH_COMTENT_LOCATION).
更好的选择是查找
PR_ATTACHMENT_HIDDEN
。如果已设置,则它是内嵌图像,并且在查看电子邮件时不会显示为常规附件。A better option is to look for
PR_ATTACHMENT_HIDDEN
. If it's set then it's an inline image and doesn't appear as a regular attachment when viewing the email.您要查找的属性是 PR_RENDERING_POSITION (0x370B0003)。 -1 表示附件是“正常”附件并且不是内嵌的。如果该值为 -1 以外的任何值,则表示内嵌附件,并且该值是正文中附件应呈现的位置。
这是描述它的 MSDN 页面。
编辑:
德米特里,我不同意你的评论。我有带有内联附件的 HTML 电子邮件,并且 PR_RENDERING_POSITION 正在按照我发布的 MSDN 页面中的描述工作。
The property you are looking for is PR_RENDERING_POSITION (0x370B0003). A -1 means that the attachment is a "normal" attachment and not in-line. If the value is anything other than -1, then that indicates an in-line attachment and the value is the position in the body that the attachment should be rendered at.
Here is the MSDN page describing it.
EDIT:
Dmitry, I do not agree with your comment. I have HTML email messages with in-line attachments and the PR_RENDERING_POSITION is working as described in the MSDN page I posted.