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
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
No comments:
Post a Comment