格式化邮件正文使用速度模板?

时间:2013-10-21 14:06:36

标签: java css spring velocity

我正在使用力度模板格式化邮件正文。我有下面的文件。

Sample.vm

<html>
<body>

This is an error email<p/>  //This text should be in bold

${exceptionDetails} //This exception details should be in RED font.

</body>
</html>

如何将文本格式设置为粗体,将异常详细信息设置为红色?

请帮帮我。

谢谢!

2 个答案:

答案 0 :(得分:3)

您应该使用样式声明来实现此目的。

这样的事情:

<html>
<body>
<span style="font-weight:bold">
This is an error email<p/>  //This text should be in bold
</span>
<span style="color:red">
${exceptionDetails} //This exception details should be in RED font.
</span>
</body>
</html>

您可以阅读有关此here的更多信息。

  

当您使用CSS编写HTML电子邮件时,请确保不要   使用链接的CSS文件(使用链接或@import附加的.css文件)。   这些是电子邮件客户最广泛忽略的样式表。

     

.....

答案 1 :(得分:0)

您可以使用<p style="color:red">等内联样式,因为很多电子邮件客户端都不支持...标记(包括GMail)。

http://www.htmlgoodies.com/beyond/css/article.php/3679231/How-to-Create-Great-HTML-Emails-with-CSS.htm

对于其他html格式,如粗体,斜体..结帐此链接 http://www.w3schools.com/html/html_formatting.asp