Fabian Saam
Fabian Saam

Reputation: 23

MimeKit/MailKit Question "Not recognized octetstream element in BodyPart of MimeMessage"

I currently have a issue with a MimeMessage from my email server in a C#/DOTNet Winforms Environment.

For most other messages, this works, but for this one the attachment is not parsed as an attachment in the MimeMessage.

From what I could gather, it is a .pdf-File and a .txt-File. Both are part of the BodyPart list of the MimeMessage, but both are not marked as Attachments or available in the attachment list.

Especially the PDF-File is kinda weird because it seems to be recognized as a octet-stream. Which is weird because other PDFs are properly parsed in the E-Mail Client we have created.

So, my issue is I want to interpret the body parts, but I also don't want to blindly accept all kinds of attachments and creating a security issue. As such, just iterating the body parts and trying to parse all the body parts seems risky.

Is there a easy way to fix this? To get all the attachments even if they are not marked properly as attachments in the MimeMessage?

With highest regards

Fabian Saam

I checked if it is a issue with the version of MimeKit... doesn't seem that way? Not 100%.

I also tried to save the email again, when saved with Thunderbird it seems to work properly.

Upvotes: 1

Views: 73

Answers (1)

jstedfast
jstedfast

Reputation: 38528

The PDF and text files appearing or not appearing in the MimeMessage.Attachments list is NOT related to whether they are being "parsed" correctly vs not correctly, it is a matter of whether they have a Content-Disposition header with a value of attachment.

So, my issue is I want to interpret the body parts, but I also don't want to blindly accept all kinds of attachments and creating a security issue. As such, just iterating the body parts and trying to parse all the body parts seems risky.

I don't see how this would be any riskier than trusting everything in the MimeMessage.Attachments list.

Upvotes: 0

Related Questions