How can I send a string to an email with new lines (carriage returns) included?
The problem is that I am sending the string to an email, and the email strips out the carriage returns.
Dim myApp As New Process
emailStringBuilder.Append("mailto:")
emailStringBuilder.Append("&subject=" & tmpID & " - " & subject)
emailStringBuilder.Append("&body= " & msgStringBuilder.ToString)
myApp = System.Diagnostics.Process.Start(emailStringBuilder.ToString)
I’m guessing you’re adding to your StringBuilder without newlines as I’ve just tested it and it works fine for me.
For the above code I get the following output
Hope this helps.
EDIT
Ok, so based on the new information (about the email) the above still holds true. If you add to a stringbuilder with
.Appendyou will lose, or more correctly, not see newlines. Instead you must use.AppendLinewhich will add the all important CR and LF codes onto the end of your string.However, I am a little confused how you are sending email. I’ve seen it done this way from a webpage before but never from vb.net. Sending an email this way will almost certainly force you to send an email without newlines!!
Can I suggest you look at the the following from Microsoft on how to send email from Visual Basic using the System.Web.Mail namespace. It’s not hard and you’ll get a lot more control over the email you send this way….
Microsoft example