【发布时间】:2011-07-25 22:29:51
【问题描述】:
我的电子邮件内容文本是
String text = "Hey, You are create a new Account! Best, MyTeam";
如何将文本格式化为:
嘿, 您正在创建一个新帐户! 最好的,我的团队【问题讨论】:
标签: java spring email velocity
我的电子邮件内容文本是
String text = "Hey, You are create a new Account! Best, MyTeam";
如何将文本格式化为:
嘿, 您正在创建一个新帐户! 最好的,我的团队【问题讨论】:
标签: java spring email velocity
SimpleMailMessage 只能处理纯文本消息,因此您需要在字符串中嵌入显式换行符:
String text = "Hey,\n\nYou are create a new Account!\n\nBest, MyTeam";
velocity 或 freemarker 等模板系统可能会使这更容易。
如果要处理 HTML 消息,需要使用JavaMailSender 和MimeMessagePreparator。
【讨论】:
试试
String text = "Hey, You are create a new Account!/n Best, MyTeam";
或者这个(如果它必须在某个 HTML 页面中)
String text = "Hey, You are create a new Account!<br/> Best, MyTeam";
或
String text = "Hey, You are create a new Account!" +System.getProperty("line.separator") + "Regards, MyTeam";
【讨论】: