Showing posts with label methos. Show all posts
Showing posts with label methos. Show all posts

Monday, March 26, 2012

StringBuilder AppendLine dont print Line breaks in my emails!

Hello... I'm working with StringBuilder to create a message to send via text email.

My methos is:

StringBuilder retorno = new StringBuilder();

retorno.AppendLine ( "A lot of text 1" );
retorno.AppendLine ( "A lot of text 2" );

return retorno.ToString() ;

Well.. I this last line I return the text to the message, but the email arrives without line breaks.

What can i do? thanks!

if you email format is in HTML, then you can use tag "<BR>" to create a line break

StringBuilder sb = new StringBuilder();
sb.Append("A lot of text 1");
sb.Append("<br>");
sb.Append("A lot of text 2);
return retorno.ToString() ;

else

you may try using \r\n, sb.Append("XXX\\r\\nXXXX");


have you tried for this one ?? it shoud work as it worked for me..

 StringBuilder retorno =new StringBuilder(); retorno.AppendLine("A lot of text 1"); retorno.AppendLine("<br />"); //....append a <br /> Tag... retorno.AppendLine("A lot of text 2"); Response.Write(retorno.ToString());

hope it helps./.