Fórum

Adding custom email templates

thumbnail
Jay Trivedi, modificado 11 Anos atrás.

Adding custom email templates

Regular Member Postagens: 109 Data de Entrada: 24/11/12 Postagens Recentes
Hey I want to create my own template for email and every time when a mail goes out its body gets attached to that template and then my template mail is sended over. I am really very confused about what to do. i.e Should i create a hook, create my custom mail vm template and than i should call that template in my portlet project? If yes! then how?
or
Should i create an vm file in my same portlet project then how?
please any one give me a example to come over this little problem.

I tried to create a vm file and stored in html/<namespace>/templates/mytemplate.vm, Is it correct ?
after creating it i was not able to call it to my action class.

try {
String from = "testmail@gmail.com";
String to = "testmail@gmail.com";
String subject = "mail-subject";
String body = "this mail is send via action class of liferay";

InternetAddress Ifrom = new InternetAddress(from, "Jay");
InternetAddress Ito = new InternetAddress(to,"Jay Trivedi");

//I want to add my body part to e-mail template, where should i save my vm or tmpl file and how to call it here in action class. in liferay6.1

MailMessage message = new MailMessage(Ifrom,Ito, subject, body,true);
System.out.println("Mail is ready to be sended!!");
MailServiceUtil.sendEmail(message);
System.out.println("Mail Sended successfully!!");
}catch(Exception e) {
e.printStackTrace();

Thanks Jay.