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
I've find one part of my solution. When you create an email the size of image embed is to 0. So you can exclude this.
But it is not right when I read a email.
MailItem MailItemSelected = this.OutlookItem;
foreach (Attachment a in MailItemSelected.Attachments)
{
if(a.Size != 0)
a.SaveAsFile(path + a.FileName);
}
When I read email I found a solution, but it is not very nice. So I write it, but if anybody think have better, I like it. In my example I try to get the Flag property with the PropertyAccessor, if it's a embed image, it's ok else I've an exception that be raise.
MailItem MailItemSelected = this.OutlookItem;
foreach (Attachment a in MailItemSelected.Attachments)
{
bool addAttachment = false;
try
{
string schemaPR_ATTACH_FLAGS = "http://schemas.microsoft.com/mapi/proptag/0x37140003";
a.PropertyAccessor.GetProperty(schemaPR_ATTACH_FLAGS);
}
catch
{
addAttachment = true;
}
if (addAttachment && (a.Size != 0))
a.SaveAsFile(path + a.FileName);
}