【问题标题】:format email body using velocity template?使用速度模板格式化电子邮件正文?
【发布时间】:2013-10-21 22:23:51
【问题描述】:

我正在使用速度模板来格式化邮件正文。我有以下文件。

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>

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

请帮帮我。

谢谢!

【问题讨论】:

  • 使用级联样式表。
  • 和普通html一样吗?谢谢!

标签: java css spring velocity


【解决方案1】:

您应该使用样式声明来实现这一点。

类似这样的:

<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 文件)。 这些是电子邮件客户端最常忽略的样式表。

.....

【讨论】:

    【解决方案2】:

    您可以使用像&lt;p style="color:red"&gt; 这样的内联样式,因为许多电子邮件客户端不支持 ... 标签(包括 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

    【讨论】:

      猜你喜欢
      • 2014-02-10
      • 2011-06-02
      • 2020-05-09
      • 1970-01-01
      • 1970-01-01
      • 2016-02-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多