lazaro-santin
lazaro-santin

Reputation: 11

Enviroment.NewLine returns blank space

I'm using Enviroment.NewLine property to separate lines of string of characters that I will send via email through an smtpclient. I will omit the part of declaring the mail message.

For example:

Dim sb as StringBuilder
sb.Append("This is my first line")
sb.Append(Enviroment.NewLine)
sb.Append("This is my second line")

When I do a:

myMailMessage.Body = sb.ToString

No lines are separated. I debugged and noticed that Enviroment.NewLine is returning " "

I don't understand why it is happening, it is supposed to return a break line.

Thanks a lot.

Upvotes: 0

Views: 74

Answers (2)

pfyod
pfyod

Reputation: 717

  1. Enviroment.NewLine might show as empty string in the debugger (because there are no printable symbols).
  2. Enviroment.NewLine is platform specific to the platform you are running your code on, not to the platform of email reader. I would just use "\r\n" as it covers both, *nix and Windows. If your email is not plain-text, you can use <br/>.

Upvotes: 1

gmail user
gmail user

Reputation: 2783

Instead of Enviroment.NewLine put <br/>. And check the email in an email client.

Upvotes: 3

Related Questions