Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to formatting a text with SimpleMailMessage?

My email content text is

String text = "Hey, You are create a new Account! Best, MyTeam";

How can I format the text to:

Hey,

You are create a new Account!

Best, MyTeam
like image 855
tomasz-mer Avatar asked Mar 30 '11 08:03

tomasz-mer


People also ask

How do I enable text formatting in Outlook?

Set default format: File > Options > Compose messages in this format > HTML, Plain Text, or Rich Text. Mac: Options > Format Text switch. Outlook.com: Go to Settings > View All Outlook Settings > Mail > Compose and Reply > Compose messages in > HTML or Plain Text.


1 Answers

SimpleMailMessage can only handle plain-text messages, so you need to embed explicit line-breaks in your String:

String text = "Hey,\n\nYou are create a new Account!\n\nBest, MyTeam";

A templating system such as velocity or freemarker may make this easier.

If you want to handle HTML messages, you need to use JavaMailSender and MimeMessagePreparator.

like image 85
skaffman Avatar answered Sep 21 '22 18:09

skaffman