'asp.net - How to find outlook mail attachment by ContentId Property

I can find email attachment from a MailMessage by ContenId like the following code :

System.Net.Mail.MailMessage objNewMail = null;
System.Net.Mail.Attachment FindAttachment = objNewMail.Attachments.First(x => x.ContentId == "ii_157d139a0005732b");

But, I want to find out the attachment from Outlook.MailItem by ContenId. I tried many times, but Outlook.MailItem do not have a property like ContentId.

Can any one help me.



Solution 1:[1]

Use Attachment.PropertyAccessor.GetProperty in the Outlook Object Model. PR_ATTACH_CONTENT_ID MAPI property can be accessed by its DASL property name ("http://schemas.microsoft.com/mapi/proptag/0x3712001F").

Take a look at the message and its attachments with OutlookSpy (I am its author - click IMessage button).

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1