我熟悉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/