Search code examples
c#emailoutlookoutlook-redemption

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


I have an Outlook email and I need to process it's attachments. But when iterating through 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?


Solution

  • 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 (I am its author) 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.