具有动态HTML正文的Java电子邮件 [英] Java Email with dynamic HTML body

查看:73
本文介绍了具有动态HTML正文的Java电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Java邮件客户端中动态呈现电子邮件模板的最佳方法是什么?已经有解决这个问题的框架了吗?

What is the best way to have the email template rendered dynamically in the Java mail client ? Any frameworks already addressing this ?

推荐答案

可以使用多种框架在服务器端将某些内容呈现为HTML.它也应该能够使用它们来生成动态HTML.

There are a variety of frameworks that can be used to render something to HTML on the server side. It should be able to use these to generate dynamic HTML too.

但是...

这可能无济于事.正如此问题与解答所述,典型的电子邮件客户端不支持Javascript或CSS.如果电子邮件客户端不支持您想要使HTML动态化的机制,那么您在服务器端执行的操作就没有任何区别.

It probably won't help. As this Q&A explains, a typical email client won't support Javascript or CSS. If the email client doesn't support the mechanisms you want to use to make the HTML dynamic, then it makes no difference what you do on the server side.

另一方面,如果您只想从模板生成 static HTML,则可以使用一些第三方模板引擎来实现.此Wikipedia页面列出了其中的一些.

On the other hand, if you just want to generate static HTML from a template, there are a few 3rd-party templating engines for doing that. This Wikipedia page lists some of them.

And this page describes a way to render a JSP to a string, which could then be embedded into an email.

这篇关于具有动态HTML正文的Java电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆