How to know if attachment is a signature in an Out

2020-07-18 06:34发布

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.

2条回答
霸刀☆藐视天下
2楼-- · 2020-07-18 07:07

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.

查看更多
够拽才男人
3楼-- · 2020-07-18 07:11

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.

查看更多
登录 后发表回答