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
Shawn BoksanShawn Boksan 

Automated Email Triggers Using HTML Templates

Hello All,

I have multiple email HTML templates built.  When we change the status of a lead we would like to send an email to the lead.  Some emails are instant and some are timed e.g. 14 Days after the status is changed the email is sent.  The email template used will be based on “Lead Status” and a custom field I created “School Name”.  I know this can be done, I just need pointed in the right direction.

Thanks,
Shawn
RatanRatan
​http://www.salesforcetutorial.com/sending-emails-singleemailmessage/

This is a sample code for sending email.

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_email_outbound_single.htm

these are the methods use setTemplateId  method for your template id.

Based on Lead Status query the template and set the setTemplateId.
Shawn BoksanShawn Boksan
Ratan,

Where do I build the workflow to trigger the email and use the template?  When I set up using the workflow rules I do not have the option to use a template.

Shawn
Abhishek_DEOAbhishek_DEO
Hi Shawn,

After saving the rules, if you go to next screen and if you add "New Email ALert" action as workflow action then you will get an option to select email template.Please see in below screenshot

User-added image
 
Dave ZarateDave Zarate
Shawn,
I would like to do the same thing.  Did you ever come up with an answer to your question?  
Thanks!