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
Steve BerleySteve Berley 

mail setTemplateID not working

In the snippet below… templateID is valid and set active.  Can query it no prob.However the template does not show in the resulting email. 

If instead, I use mail.setHtmlBody() it works fine.  Any ideas why templates aren't working?
 
id templateID='00X1R000000f3T1UAI';
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setTemplateId(templateID);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

 
Maharajan CMaharajan C
Hi Steve,

Did you have enables the Available For Use in email template ?

User-added image

Also test the template using Send Test and Verify Merge Fields.

User-added image

Thanks,
Maharajan.C
mukesh guptamukesh gupta
Hi Steve,


Can you please share below detail:

1 Are you using dynimic email template 
2. object name that's you are using in email

REgards
Mukesh