I am using spring context to create the engine, I am suspect that is
where your issues are....hopefully not.....or maybe you are using spring
as well?
<bean id="velocityEngine"
class="org.springframework.ui.velocity.VelocityEngineFactoryBean">
<property
name="resourceLoaderPath"><value>/pages/velocity/</value></property>
</bean>
//engine is injected by spring context.
HashMap model = new HashMap();
Model.put("some", "stuff");
VelocityContext data = new VelocityContext(model);
StringWriter canvas = new StringWriter();
velocityEngine.mergeTemplate("template.vm", data, canvas);
String body = canvas.toString();
if you aren't using spring.......
hopefully you can extract what you need from that. :-)
Sven Richter wrote:
Thanks for your reply. That's exactly what I was trying to do for the
last 2 days. Could you please give me a code sample?
Thanks a lot,
Sven.
sgtmcd schrieb:
I took a different approach. I rendered a velocity template (using
the velocity engine) then used standard java mail api stuff, set the
body of the email as the rendered velocity template, set the mime
type to html, etc.
Shawn
Sven Richter wrote:
Hello,
Can someone please tell me a way to generate a HTML-confirmation
email from a velocity template using VelocityEmail or another class?
I know that there's a class VelocityHtmlEmail, but in that class I
can't seem to pass the Context from the Java class to the template
(there is no 'setContext()' in that class). Or maybe somebody can
suggest me another class, that I could use (with a small example on
how to use it).
Thanks a lot,
Sven.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]