0 votes

Hello,

I am using the following code to get get attachments

 foreach (MimeData attachment in email.Attachments)
        {
            attachment.FileName;
            attachment.ContentType;
            attachment.Data;
        }

I want to just get just regular attachments with out embedded images/visuals. at the moment it's extraction all the attachments (regular and embedded also). How can I get this done?

Thank you

by (850 points)

1 Answer

0 votes

It's quite easy. Use IMail.NonVisuals collection to retrieve 'real' attachments (those that have content-disposition set to attachment) only.

Mail.dll uses 4 lists to store/group email attachments:

  1. IMail.Attachments – all attachments found in the email (this list basically combines all other ones).

  2. IMail.Visuals – visual elements, attachments that should be displayed to the user. This list contains images used by HTML content for example.

  3. IMail.NonVisuals – non visual elements, 'real' attachments, content-disposition set to attachment.

  4. IMail.Alternatives – alternative content representations, for example ical appointment.

by (301k points)
...