Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Outlook attachment contains some unknown images "image00001" if I add "Outlook Item" type of attachment or share document via link

My goal is to check all attachments from email and show a message with a recommendation to upload file to cloud and share file by link if even one of them located on PC.

Currently, if I add some file from PC, in this case

item.Attachments.Count = 1;
att.Type = Outlook.OlAttachmentType.olByValue;

and I can check it like this

public bool IsAttachmentLocal(Outlook item)
{
    foreach (Outlook.Attachment att in item.Attachments)
    { 
        if (att.Type == Outlook.OlAttachmentType.olByValue && null == att.PathName)                  
        return true;
    }
}

But if I add some "Outlook Item" (message) or some file via cloud location, then item.Attachments.Cout = 5. The first element of this array is file with type olEmbeddeditem or 7(in case with cloud location file). The next four elements some unknown images with name "image00001" which are have

att.Type = Outlook.OlAttachmentType.olByValue;

and passed my checking.

I have a suspicion, that it can be thumbnail image.

How can I check the file location in this case? Can I pass these images somehow?

like image 784
Marquise Avatar asked Jan 21 '26 02:01

Marquise


2 Answers

It seems you just need to detect embedded images in Outlook. Here is a sample code for adding such images:

Attachment attachment = newMail.Attachments.Add(@"E:\Pictures\image001.jpg"
    , OlAttachmentType.olEmbeddeditem, null, "Some image display name");

string imageCid = "image001.jpg@123";   

attachment.PropertyAccessor.SetProperty(
 "http://schemas.microsoft.com/mapi/proptag/0x3712001E", imageCid);

newMail.HTMLBody = String.Format("<body><img src=\"cid:{0}\"></body>", imageCid);

So, you can do in the reverse order - get the image CID property value and check whether the message body contains any img tags with such mentions.

string imageCid = attachment.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x3712001E");

bool toSkip = newMail.HTMLBody.Contains(imageCid);
like image 98
Eugene Astafiev Avatar answered Jan 22 '26 15:01

Eugene Astafiev


7 is ATTACH_BY_WEB_REF. The attachment itself must be a *.url file. Its format is something like the following.

[InternetShortcut]
URL=http://www.mysite.demo/myfile.ext
like image 29
Dmitry Streblechenko Avatar answered Jan 22 '26 17:01

Dmitry Streblechenko



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!