我的電子郵件內容的文本是如何用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