I want to send Email through Apex and attach 2 files.
Everything is working as expected but mail body part should come from Email Template but when I am getting the email, Email template part is not showing in mail body.
EmailTemplate et = [Select id,HtmlValue FROM EmailTemplate WHERE name = 'TEST' LIMIT 1]; mail.setToAddresses(sendTo); mail.setReplyTo('email@example.com'); mail.setSenderDisplayName('Test'); mail.setSubject('TEST'); mail.setTemplateId(et.Id); mail.setSaveAsActivity(true); mail.setFileAttachments(fileAttachments); Messaging.sendEmail(mail);
I am not sure where I am doing wrong. I tried with changing the Encoding style and everything.