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
thornkthornk 

Using a Template in an apex trigger

Hello,

   We have a business requirement to send an email to external users whenever a checkbox is checked on an opportunity.  The business needs basic opportunity information but also need any attachment on the opportunity.  For this reason, I need to write an apex trigger to gather up the attachments and create the email.

 

I was hoping to leverage an email template rather than build the email within apex code and thought I would be able to use the setTemplateID parameter on a single Mail message, however it turns out that the email templates only work with Contacts, Leads and Users.

 

I was wondering if anybody has any thoughts on how to leverage a template when creating an email message in an apex trigger.  It would help with maintenance of this process in the future if we don't have to edit the code and redeploy whenever fields are updated.

 

Thank you.

Best Answer chosen by Admin (Salesforce Developers) 
thornkthornk

I have spoken to SFDC Support and they were not able to give me any solution, so it does not appear that this functionality is availalbe.

All Answers

TbomTbom

Hi,

I think you should be able to also send a template to an email address that lives on your Opp as a SFDC "Email" Type Field.

(I know you can with native Email Alerts)

 

Hope that helps,

 

Tom

thornkthornk

I have spoken to SFDC Support and they were not able to give me any solution, so it does not appear that this functionality is availalbe.

This was selected as the best answer