Untitled
unknown
plain_text
3 years ago
1.3 kB
9
Indexable
public class SendEmailAction { public class InputVariables{ @InvocableVariable public Account account; } @InvocableMethod (label='Send Email notify') public static void sendEmail(List<InputVariables> inputVariables){ List<EmailTemplate> SEEmailTemplate= [Select Id, Name, Subject, DeveloperName, Body from EmailTemplate where DeveloperName= 'Notification_for_New_Account_Assigned']; Account passInAccount= inputVariables.get(0).account; Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); String emailAddr = [select Email from User where Id = :passInAccount.OwnerId].Email; String[] toAddresses = new String[] {emailAddr}; String plainBody = SEEmailTemplate[0].Body; plainBody = plainBody.replace('{!Account.Name}', passInAccount.Name); String subject = SEEmailTemplate[0].Subject; mail.setTemplateId(SEEmailTemplate[0].Id); mail.setToAddresses(toAddresses); mail.setTargetObjectId(passInAccount.OwnerId); mail.saveAsActivity = false; mail.setPlainTextBody(plainBody); mail.setSubject(subject); Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail }); } }
Editor is loading...