Don't save embed image that contain into attachements (like signature image)
attachment, c#, outlook-addin, vsto
Solution
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);
}
Problem
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 attachment. But I don't want save that image. Outlook (application) hide this attachment in the area attachment ! So why not me :-( My code is very simply : ``` MailItem MailItemSelected = this.OutlookItem; foreach (Attachment a in MailItemSelected.Attachments) { a.SaveAsFile(path + a.FileName); } ``` But I don't find a test for don't save the image of the signature.