How to format text using SimpleMailMessage?

My email text

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

How can I format the text:

  Hey

 You are create a new Account!

 Best MyTeam
+4
source share
2 answers

SimpleMailMessage can only process text messages, so you need to embed explicit line breaks in your line:

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

A template system such as speed or freemarker can make this easier.

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

+3
source

Try

String text = "Hey, you are creating a new account! / N Best, MyTeam";

or this (if it should be inside some HTML page)

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

or

 String text = "Hey, You are create a new Account! + System.getProperty("line.separator"); + Best, MyTeam"; 
0
source

Source: https://habr.com/ru/post/1345840/


All Articles