How can I send a mail message with multiple lines in the body?

Ivo Limmen

You need to manually add the new lines to the message. Try the following:

...
StringBuffer sb = new StringBuffer();

sb.append("This is line 1

");
sb.append("This is the second line

");
sb.append("...");

msg.setText(sb.toString());
...
You must use one bodypart with text but the text can contain multiple lines. So you need to use the .

You can also use
String newline = System.getProperty("line.separator");
to get the platform-specific line separator. Keep in mind that if you display the text as HTML, the newline is just white space.

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact