I want to use Java Mail to send an email but I want to define the content and structure of the mail using a velocity template. Is there any way to make a conversion of the velocity template that yields a String in the way I could use it like this:
String html = velocityConversion_or_whatever();
MimeBodyPart htmlPart = new MimeBodyPart();
htmlPart.setContent(html, "text/html");
Thanks.
Velocity can render a template into a
StringWriter, so from there it’s pretty straightforward to grab the HTML out of your string. Assuming you’ve already configured your Velocity engine you can do this: