Is there a class or set of functions built into the .NET Framework (3.5+) to parse raw emails (MIME documents)?
I am not looking for anything fancy or a separate library, it needs to be built-in. I'm going to be using this in some unit tests and need only grab the main headers of interest (To, From, Subject) along with the body (which in this case will always be text and therefore no MIME trees or boundaries). I've written several MIME parsers in the past and if there isn't anything readily available, I'll just put together something from regular expressions. It would be great to be able to do something like:
MailMessage msg = MailMessage.Parse(text);
Thoughts?
Very impressed with free, open-source (MIT-licensed) and fast MimeKit
Check out Mail.dll .NET mail component, it has build in MIME support, unicode, and multi-national email support:
Please note that Mail.dll is a commercial product that I've created.
You can download it here: https://www.limilabs.com/mail.
check out our Rebex Secure Mail which includes a (IMHO) decent S/MIME parser. Features include:
The parser is part of Rebex Secure Mail and you can download it here.
I recommend IMAP and MIME parser libs from Lumisoft. Which I used before and its easy to work with. You can download it from here: http://www.lumisoft.ee/lsWWW/Download/Downloads/Net/ The lib has many other protocols like ftp, pop3, etc and I'm sure the sc is available. Try to google for it, also you can find it on codeproject.com regards
No, there is no way to do that yet. Microsoft has not created a Text-to-Message convertor just as they haven't created a POP3 or IMAP library. Unfortunate.
I know you said no external libraries, but I have a library posted on codeplex:
https://bitbucket.org/otac0n/mailutilities
It has been tested with over 40,000 real-world mail messages.
I'm not too happy with my namespace choice, but... I'm too lazy to change it.
PS:
Internally, my library uses these regexes as a parser: