Forums de discussion

Mail templates

Marsin Alexandre, modifié il y a 14 années.

Mail templates

New Member Publications: 13 Date d'inscription: 10/03/10 Publications récentes
Hello,

Is it possible to send email (Liferay mail service) with templates set in webContent ?
By the way I can't found an API to get a templates via its ID, is there a way I can get the content in my portlet ?

Thanks
Arun Kumar S, modifié il y a 14 années.

RE: Mail templates

Regular Member Publications: 182 Date d'inscription: 23/06/08 Publications récentes
Marsin Alexandre:
Hello,

Is it possible to send email (Liferay mail service) with templates set in webContent ?
By the way I can't found an API to get a templates via its ID, is there a way I can get the content in my portlet ?

Thanks


Use the below api to fetch the template

JournalTemplateLocalServiceUtil.getTemplate(templateId)

HTH,
Arun
Marsin Alexandre, modifié il y a 14 années.

RE: Mail templates

New Member Publications: 13 Date d'inscription: 10/03/10 Publications récentes
Hi,

I try to evaluate my template with data before send it via mail, but it seems to not work correctly.
Data are not replaced in the template.
What is wrong with this code ?


JournalTemplate tmpl = JournalTemplateLocalServiceUtil.getTemplate(34324, "44939");

Map<string, object> variables = new HashMap<string, object>();

variables.put("signature", "test signature");
variables.put("description", "test description");

String body = VelocityUtil.evaluate(tmpl.getXsl(), variables);

InternetAddress from = new InternetAddress(*********, ***********);
InternetAddress to = new InternetAddress(********, *********);
MailMessage message = new MailMessage(from, to, "test", body, true);
MailServiceUtil.sendEmail(message);

</string,></string,>


Thanks for your help