Home » Liferay Portal » English » 2. Using Liferay » General

Combination View Flat View Tree View
Threads [ Previous | Next ]
Jay Trivedi
Adding custom email templates
December 3, 2012 10:00 PM

Jay Trivedi

Rank: Regular Member

Posts: 107

Join Date: November 23, 2012

Recent Posts

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?
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 = "";
String to = "";
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!!");
System.out.println("Mail Sended successfully!!");
}catch(Exception e) {

Thanks Jay.