function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jeff Bryant 16Jeff Bryant 16 

Using custom setting for email list

I'm trying to use a custom setting to store email addresses to be used when sending out an Excel file of an Apex job that deactivates users and I'm not exactly sure how to do so. I setup a custom setting as a string and put 'avalidemailaddress@email.com' but I keep getting "Method does not exist or incorrect signature" error.
Currently, my code is
Batch_Settings__c batchSettings = Batch_Settings__c.getInstance();
String deactivationEmails = batchSettings.DeactivatedUsersListemails__c;
// Apex batch code
Messaging.EmailFileAttachment csvAttc = new Messaging.EmailFileAttachment();
.........
email.setToAddresses(deactivationEmails); // This is where the error is occuring
Any help is appreciated!
Vishwajeet kumarVishwajeet kumar
Hello,
Messaging.setToAddresses accepts Array of emails. 

Use Array to store "to addresses, something like this : 

String[] sendingTo = new String[]{batchSettings.DeactivatedUsersListemails__c};
email.setToAddresses(sendingTo); 



Thanks