java - 使用接缝:mail in Message Driven Bean

标签 java email jsf seam template-engine

我熟悉JSF,并且有自动创建电子邮件的需求。我喜欢用 JSF 风格的 seam:mail 模板化电子邮件的想法,并且还使用 JSF 组件:

<m:message>
  <m:from name="Peter" address="peter@example.com" />
  <m:to name="#{person.firstname} #{person.lastname}">#{person.address}</m:to>
  <m:subject>Try out Seam!</m:subject>
  <m:body>
    <p><h:outputText value="Dear #{person.firstname}" />,</p>
    <p>You can try out Seam by visiting 
    <a href="http://example.com">http://example.com</a>.</p>
    <p>Regards,</p>
    <p>Pete</p>
  </m:body>
</m:message>

据我了解 Documentation ,尤其是这个片段(缩短),

So, now you have your email template, how do you go about sending it? Well, at the end of rendering the m:message the mailSession is called to send the email, so all you have to do is ask Seam to render the view,

@In(create=true) private Renderer renderer;

public void send()
{
   renderer.render("/simple.xhtml");
   facesMessages.add("Email sent successfully");
} 

这是在公共(public) JSF (Facelet) 页面中调用的。是否有机会在消息驱动 Bean 中执行此操作?或者我应该转向其他模板引擎?参见 Suggestions for Java email templating?

最佳答案

据我所知Message Driven Beans are for receiving messages 。我认为这对于您自动创建电子邮件的要求没有多大意义。

无论如何,this Seam tutorial告诉您有关使用 seam 发送和接收 JMS 消息的信息。也许它可以满足您的目的,无论它是什么。

关于java - 使用接缝:mail in Message Driven Bean,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6690762/

相关文章:

jsf - org.omnifaces.VetoAnnotatedTypeExtension.processAnnotatedType(@Observes ProcessAnnotatedType) 接收所有注释类型的事件

jsf - 关于页面加载时间测量的想法

java - 像 Chrome 一样在 webview 上显示 xml

java - Android 虚拟设备挂起的 Eclipse 调试器?

amazon-web-services - Amazon SES 在电子邮件 header 中添加随机数

c# - POP3接收邮件编码C#

jsf - 无法在 Tomcat 7 中初始化 FacesServlet - ClassNotFoundException

java - Hibernate JPA 映射中的问题

java - 如何使用java流过滤 map 的 map

html - 是否可以使用 HTML 通过电子邮件发送 vim 的内容