I want to send an e-mail from an ASP.NET application using the SmtpMail object. I have created an HTML string and sent the email in HTML MailFormat. In so doing, I can see the string in debug mode before the email is sent. As far as I can tell, the string is correct.
However, when I receive the email and click on "view source", I see an extra whitespace + linebreak characters that was added to the HTML, always at position #990. In some cases it is added in a place where it doesn't make a difference and the e-mail looks fine. In some cases it 'ruins' the HTML and the email doesn't read right. For example, say the whitespace is added into a tag, and "<td>" becomes "<t d>"... You get the idea. Why is this? Any ideas on how to fix it?
It appears this behavior is consistent with all SMTP servers. It doesn't have anything to do with your Windows 2003 Server or the behavior of SmtpMail.
I took a look at the SMTP RFC 821 specifications and it specifies "The maximum total length of a text line including the <CRLF> is 1000 characters."
So, I believe the SMTP servers are doing something at about 1000 characters (990 in your case because I suspect there are some leading characters that are not getting counted). I experienced different behavior on two different SMTP servers. One inserted a single space character and the other inserted and explanation point and a space character.
To circumvent this behavior, I suggest you place some vbCrLf character sequences into your output stream at locations in the stream that will not modify the behavior of the output. Probably putting a vbCrLf between "><" characters will not modify the HTML behavior.
Dig Deeper on Win Development Resources
Related Q&A from Samuel Matzen
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.