0

I am trying to send an html email template body in the mail from apex code by using messaging.renderStoredEmailTemplate method but it is sending plain text not html body.

Here is the code :

 EmailTemplate tempID = [SELECT Id,HTMLValue,Name FROM EmailTemplate WHERE DeveloperName =: label.ApprovalProcessEmailTemplate];
            string emailBody= messaging.renderStoredEmailTemplate(tempID.Id,newQuotes.OwnerId,newQuotes.Id).getHtmlBody();
            mail.setHtmlBody(emailBody);
            List<String> users = new List<String>{ userInfo.getUserEmail()};
            mail.setToAddresses(users);
            
            
            Messaging.SendEmailResult [] result = Messaging.sendEmail(new list<Messaging.SingleEmailMessage> {mail});
           

Expected :

enter image description here

Actual :

enter image description here

email is not sending in proper html format.

2
  • How does your template code look like? Are you using any table?
    – manjit5190
    May 31, 2021 at 9:08
  • yes it uses html table to structure the details May 31, 2021 at 16:04

0

You must log in to answer this question.

Browse other questions tagged .