You need to sign in to do that
Don't have an account?
Tamil
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 });