jstedfast / MimeKit

A .NET MIME creation and parser library with support for S/MIME, PGP, DKIM, TNEF and Unix mbox spools.
http://www.mimekit.net
MIT License
1.81k stars 367 forks source link

MimeMessage.Attachments.Count() remains 0 while there are attachments in the original email #334

Closed benoitverstraete closed 6 years ago

benoitverstraete commented 6 years ago

Hello,

First of all, thank you for this wonderful library !

Unfortunately, I have an issue on some specific emails (always the same): there are no attachments listed in the MimeMessage, while there are in the original email. It is on a gmail account (it works on an exchange for example). The email is retrieved from the IMAP protocol and this procedure :

foreach (var summary in inbox.Fetch(0, -1, MessageSummaryItems.Full | MessageSummaryItems.UniqueId)) { var message = inbox.GetMessage(summary.UniqueId); // message.Attachments.Count() = 0 }

I tried some other procedures like : message.BodyParts.Where(x => x.IsAttachment).Count() = 0

I've attached the original email to the issue original_msg.txt

Thanks a lot for your support.

PS: I use the last version of the library (from nuget).

jstedfast commented 6 years ago

I take it you are looking for the MIME part that contains the VELUX 5011357635.pdf?

That's not an attachment ;-)

Attachments are MIME parts which contain a Content-Disposition header with a value of attachment. If the Content-Disposition header doesn't exist or has a value of inline, then IsAttachment will be false.

You will need to iterate over BodyParts and use your own criteria for determining if the part is what you are looking for.