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
sadik Shaiksadik Shaik 

letterhead is not being shown for emails in apex

I have an email template with letetrhead and i am accessing it in code and replacing some merge fields.The lettehead which i have is not being shown in the emails but the getting the content as it is. Any idea on this, thanks in advance.
Khan AnasKhan Anas (Salesforce Developers) 
Hi Sadik,

Greetings to you!

You can query the BrandTemplateId from the EmailTemplate object, and from there, you can query the BrandTemplate, which is in HTML form.
 
EmailTemplate et = [SELECT BrandTemplateId FROM EmailTemplate WHERE brandtemplateId.name='Your_LetterHead_Name' LIMIT 1];
System.debug('Email template's letter head -> ' + et.brandtemplateId);

You need to put the letterhead in sethtmlbody method to access it.

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future.

Thanks and Regards,
Khan Anas
sadik Shaiksadik Shaik
Hi Khan Anas,
Thanks for the replay. I am able to get this Brandtemplate id, but how to put the letterhead in sethtmlbody method, could you elobarate more.

Thanks in advance.