Web Mail client helper not translating newlines in body of msg (mvc3/asp.net)?
开发者_如何转开发Can somebody tell me why newlines are not being translated in the email message when passed in as the body of the web mail helper?
string body = "First line here" + Environment.NewLine + Environment.NewLine +
"Here is a newline...";
WebMail.Send(
"myemail@mycom.com",
"Subject",
body, "myemail@mycom.com");
Output is all on the same line in the email message itself. Thx!
Default value for parameter isBodyHtml from send method is true that's why Environment.NewLine is ignored. If you'll set isBodyHtml = false it will work.
WebMail.Send(to: "mail@gmail.com", subject: "Test", isBodyHtml:false, body: "First line here" + Environment.NewLine + "Second line.");
精彩评论