如何使用SimpleMailMessage格式化文本? [英] How to formatting a text with SimpleMailMessage?
本文介绍了如何使用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
推荐答案
SimpleMailMessage
仅能处理纯文本消息,因此您需要在字符串中嵌入明确的换行符:
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";
速度或freemarker之类的模板系统可能会使此操作变得更容易。
A templating system such as velocity or freemarker may make this easier.
如果要处理HTML消息,则需要使用 JavaMailSender
和 MimeMessagePreparator
。
If you want to handle HTML messages, you need to use JavaMailSender
and MimeMessagePreparator
.
这篇关于如何使用SimpleMailMessage格式化文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文