System.Net.Mail creating invalid emails and eml files? Inserting extra dots in host names

This is actually per RFC 2821 (4.5.2 Transparency)

Before sending a line of mail text, the SMTP client checks the first character of the line. If it is a period, one additional period is inserted at the beginning of the line.

.Net is just storing the file in “ready to transmit” mode which means that it doesn’t have to monkey with the email before sending, instead it can transmit it as is. Unfortunately this format isn’t 100% the same as Outlook Express’s EML format apparently. You should be able to set the encoding to UTF-8 (or something similar) and that will kick in Base-64 encoding for you.

mail.BodyEncoding = System.Text.Encoding.UTF8;

Leave a Comment