我的电子邮件内容的文本是如何用SimpleMailMessage格式化文本?
String text = "Hey, You are create a new Account! Best, MyTeam";
如何设置格式的文本:
Hey, You are create a new Account! Best, MyTeam
我的电子邮件内容的文本是如何用SimpleMailMessage格式化文本?
String text = "Hey, You are create a new Account! Best, MyTeam";
如何设置格式的文本:
Hey, You are create a new Account! Best, MyTeam
SimpleMailMessage
只能处理纯文本消息,所以你需要嵌入明确的行您的字符串中的破音:
String text = "Hey,\n\nYou are create a new Account!\n\nBest, MyTeam";
模板系统,如速度或freemarker可能会使这更容易。
如果要处理HTML消息,则需要使用JavaMailSender
和MimeMessagePreparator
。
尝试
字符串文本=“嘿,你是创建一个新帐户/ 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"); + Best, MyTeam";
这不起作用。我收到“嗨,你正在创建一个新账户!
Best,MyTeam” – user6778654 2011-03-30 08:52:14
显示更多关于它的信息。那个变量在哪里被调用?你尝试使用分隔线吗? – sfrj 2011-03-30 08:55:45