We have a flow that stores the collection of Ids with Email address and we want to pass those Ids to send an email from Apex. I'm Trying to call the apex but it gives me error list has no rows. Couldn't find the any answer. I'm not sure how to pass the Multiple Email parameters from Invocable.
Updated Code & Screen shot. I need to be able to pass the correct Email address collection to the Apex invocable parameter string. Could you please tell me where I'm doing wrong? Do i still require loop variable?
public class SendEmailAction {
@InvocableMethod(label='Send SE Email Notification')
public static void SendSENotification(List<string> Emailaddresses){
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(string Ids : Emailaddresses) {
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setTemplateId(SEEmailTemplate[0].Id);
mail.setTargetObjectId(UserInfo.getUserId());
mail.setToAddresses(RecepientList);
mail.setSaveAsActivity(false);
mails.add(mail);
mail.setOrgWideEmailAddressId(lstEmailAddress[0].Id);
}
Messaging.sendEmail(mails);
}
}