0 votes

I use this part of code to retrieve all attachments of an email

foreach (MimeData mime in email.NonVisuals)
{
     mime.Save(System.IO.Path.Combine(myPath, mime.SafeFileName));
}

But if the email has .MSG attachments, they are not saved.

Any ideas to get .MSG attachments?

Thanks.

by

1 Answer

0 votes

Without the raw eml data it's hard to tell definitely what the problem is.

My guess is that .msg files are attached as inline elements - they don't have "content-dispostion" header set to "attachment".

Please check if they are available in IMail.Visuals collection (or IMail.Attachments).

Mail.dll uses 4 collections to represent email attachments:

  • IMail.Attachments – contains all attachments (includes all other collections).
  • IMail.Visuals – visual elements, files that should be displayed to the user ("content-dispostion" header set to "inline" or no "content-dispostion" header).
  • IMail.NonVisuals – non visual elements, “real” attachments ("content-dispostion" header set to "attachment").
  • IMail.Alternatives – alternative content representations, for example ical appointment.

In most cases using IMail.Attachments is the way to go.

by (301k points)
...