See RFC 2822, section 2.1.1 and 2.2.3 to start
Does System.Net.Mail.MailMessage auto fold its header fields if their content exceeds the maximum length restrictions? RFC2822 states that a header field must not exceed 998 characters per line. To get around that, CRLF may be inserted to have a header field take up more than one line.
Thoughts?
The
MailMessageclass does not do any automatic folding at least until it’s sent using anSmtpClient. It’s only when the message is sent that .NET performs automatic folding of the header fields in order to construct the MIME message. You can check this by accessingMailMessage.Headersafter the message is sent.The folding may occur at several places depending if the header field needs to be previously encoded. For example if the subject contains non US-ASCII characters it must be encoded in Base64 or Q encoding. In this case the classes responsible for the encoding also do the folding.
If you use Reflector you can take a look for example at the
MailWriterclass which is one of the classes that performs folding and that, at least in .NET 2.0, uses the recommended default line limit of 78 characters per line as specified in RFC2822.