I'm trying to pass in the flow variable collection of Email addresses to Apex action to send out one email to each email address. I got some idea from Question, the code works fine when i ran it from anonymous window (by passing list of Email addresses) but it doesn't work with the flow. Can someone point me what I'm doing wrong?
Here is the code
public class SendEmailAction {
@InvocableMethod(label='Send SE Email Notification')
public static void SendSENotification(List<List<String>> Emailaddresses){
List<String> getEmails = new List<String>();
//List<string> getEmail = Emailaddresses[0];
List<OrgWideEmailAddress> lstEmailAddress=[select Id from OrgWideEmailAddress WHERE Address='[email protected]'];
List<EmailTemplate> SEEmailTemplate= [Select Id, Name, DeveloperName
from EmailTemplate
where DeveloperName= 'Safety_Event_New_Event_Reported'];
Messaging.SingleEmailMessage[] mails = new Messaging.SingleEmailMessage[0];
for(List<String> Ids : Emailaddresses) {
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setTemplateId(SEEmailTemplate[0].Id);
mail.setTargetObjectId(UserInfo.getUserId());
mail.setToAddresses(getemails);
mail.setSaveAsActivity(false);
mails.add(mail);
mail.setOrgWideEmailAddressId(lstEmailAddress[0].Id);
}
Messaging.sendEmail(mails);
}
}
getemails
is not declared. IsIds
supposed to begetemails
?