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
TamilTamil 

Apex Email: Html template displaying null value

I am using the following code to send an email to user using HTML template. The issue which i am facing is i am getting email but the body of the email is blank. Am I doing any mistake in the code. When I test the email template it works fine.
 
List<String> sendTo = new List<String>();
EmailTemplate et = [SELECT Id,Subject, HtmlValue,Body FROM EmailTemplate WHERE Name =:'MyTemplate'];    
String subject = et.Subject;
subject = subject + ' '+ p.Name;
sendTo.add(p.Request__r.Reviewer__r.email);
sendEmailSet.setToAddresses(sendTo);
sendEmailSet.setSubject(subject);
String emailBody = et.HtmlValue;
emailBody = emailBody.replace('{!Request__c.Link}', URL.getSalesforceBaseUrl().toExternalForm() +'/'+p.Id);
sendEmailSet.setHtmlBody(emailBody);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { sendEmailSet });