Search code examples
.netmimemailmessage

Convert MIME tree to MailMessage


I'm writing a a C# program that processes and forwards email messages. I have a POP3 library and a MIME parser, and I need to copy the MIME tree into a System.Net.Mail.MailMessage.

What is the best way to map different MIME parts to AlternateViews, LinkedResources, and Attachments?

EDIT: That will work with all mail clients (both sending and receiving)


Solution

  • Right now, I'm copying anything with a Content-Disposition which isn't inline, or with a MIME category of anything other than Text or Image, to an Attachment, anything inline, or anything with a MIME category of Image to a LinkedResource on the HTML view or the last view, and anything else as an AlternateView. (I haven't tested this yet)