Search code examples
.netmime

Extract MIME body staying with pure .NET framework


Since .NET Framework already have System.Net.Mime namespace and is able to parse Http headers, I hope there should be also "standard" or "hidden" method to extract mime body (base64 encoded) from message (passed as a string or stream).

Where?

P.S. now I use regexps but that is not so interesting end not so durable... P.P.S .Net Framework 3.5


Solution

  • I have not found any interesting inside .NET framework, after several hours of exploring with reflector.

    1. System.Net.Mime classes are used only to deserialize data (for .NET SMTP client that can only send emails).

    2 I found that HTTP headers parser is also not very useful, have a look at
    WebHeaderCollection's class, internal DataParseStatus ParseHeaders(byte[] buffer, int size, ref int unparsed, ref int totalResponseHeadersLength, int maximumResponseHeadersLength, ref WebParseError parseError) method. It requires to know where to stop. That means preparsing.