function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
JTecJTec 

Using email templatte from visualforce form

Hi,


We have developed a visualforce page to replace the Send email funcionality from a determinate custom object to give it more funcionallity.


Is ther any way to use a email template like in the standard "Send email"? Can we load in our VF page a template email and load the dinamyc field before to send this? We are trying this since some days and there is no way.


Thanks for all

suresh.csksuresh.csk

Hi.

 

Yes this is possible.Salesforce emailtemplate OBject name is

For example:

 

1.Load all your Email Template Name to a dropdown list

2.For example when the  user selects "Email Template A" the corresponding

email context  ie subject,email content are displayed in VF.

3.Add you text fields to the VF page so this is appended to the email while sending.

 

Add corresponding variable in Apex Class the email id,email subject,email content and use the following 

Messaging.SingleEmailMessage method  to send the mail

 

Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setReplyTo('xx@x.com);
mail.setSenderDisplayName(X company);
mail.setToAddresses(userEmailID);
mail.setSubject(emailTmplate);
mail.setPlainTextBody(TemplateBody);
Messaging.SendEmailResult[] result =  Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

 

let me know whether you got it or not.

 

cheers

suresh