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
jameskCAjameskCA 

How to include apex variables in HTML email template through apex?

I'm trying to create an email that sends through apex as we need to setup custom reply to address.  I have an custom html template and was going to use the setTemplateId method to use the template that is already made.  The problem is, the email is based on a custom project object.

The project has a user lookup field for the sales rep.  What I want is to also include the sales rep name, phone number, and email to put at the bottom of the email as their signature.  Those aren't available through the gui template editor.  I tried to just put them in the template anyway like this:
{!Project__c.Sales_Rep__c.Name}
{!Project__c.Sales_Rep__c.Email}
{!Project__c.Sales_Rep__c.Phone}

But the email that sends has blanks for those values.  In apex, I can get all those values through soql.  Is there a way to insert / include them in the template somehow?  Is there a better way to do this?  Thanks in advance.