Thursday, 28 November 2019

Prepare email message with Template using renderStoredEmailTemplate method

Hi ,



When we have to use email template then we have to use few methods like "setTemplateId" ,"setWhatId" etc.


But we can use single method "renderStoredEmailTemplate"to  prepare the message from email template. We have to be careful when we use this method because it counts SOQL query.


Eg:

Messaging.SingleEmailMessage message = Messaging.renderStoredEmailTemplate(templateid,whoId,whatId);
message.setsaveAsActivity(false);
Messaging.sendEmail(new List<Messaging.Email>{message});




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

Grounding Prompt Templates with Apex Merge Fields

 Hi, You can include an Apex merge field in a prompt template to surface data retrieved from a SOQL query or an external API. Apex is also u...