How to know if attachment is a signature in an Outlook email

喜夏-厌秋 提交于 2020-02-01 05:27:04

问题


I have an Outlook email and i need to process it's attachments. But when iterating thru the attachments, if the attachment is a signature i want to skip it.

To know if the attachment is a signature i am using:

outlookMailItem.Attachments[i].PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x3712001E");

But i am getting an Outlook security alert.

Is there another way using a safer code? Can it be done using Redemption?

Thank you for your time.


回答1:


PR_ATTACH_CONTENT_ID property is a good indication that an attachment is an embedded image, but there are attachments that have PR_ATTACH_CONTENT_ID property set, but they are not embedded images (Lotus Notes likes to set PR_ATTACH_CONTENT_ID on all attachments). Even if PR_ATTACH_CONTENT_ID is not set, Outlook can use PR_ATTACH_CONTENT_LOCATION or PR_ATTACH_LONG_FILENAME to load an embedded image. The only real test is to parse the HTML body and figure out which <img> tags refer to the attachments. Redemption will let you access that property using RDOAttachment.Fields, you can also use RDOAttachment.Hidden property, which jumps through a few hoops to figure out whether an attachment is an embedded image and not a "real" attachment.




回答2:


RDOAttachment.Hidden property works well only if the email format is HTML. For emails in Rich Text Format, the signature image would be treated as any other attachment and will have this value as false. A better bet would be to use "Attachment.Type", which works for both HTML and Rich Text. For signature, it would always be olOLE and for other attachments, it would be olByValue. So, you can filter the signature images using this property. However, note that, if the email format is Rich Text and if you have a screenshot embedded within the email, it's treated as olOLE type.



来源:https://stackoverflow.com/questions/9124913/how-to-know-if-attachment-is-a-signature-in-an-outlook-email

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!