I work on a VSTO in c#. When I click on button I save attachment in a folder. My problem is : when I have a rich email with an image in the signature, I have a element in my
The flags workaround didn't work for me. I'm developing a solution for Outlook 2016 and I managed to filter the attachments using this code:
foreach (Attachment attachment in mailItem.Attachments)
{
//exclude inline images
if (!mailItem.HTMLBody.Contains(attachment.FileName))
{
//the attachment is not an inline attachment, YOUR CODE HERE
}
}
which is basically checking in the HTML body if each of the attachments is mentioned in a tag.
EDIT: the previous method may skip an attachment if you type its name in the body. This is less likey to skip false positives
if (!mailItem.HTMLBody.Contains("cid:" + attachment.FileName))