0

Want to send mail from APEX, From the LWC UI component, I send the following email list and get an error.

To remove the double-quote from the email string and put in the string list I used the following syntax

 List<String> emails;
      if (toAddressesArray != '') {
        emails = toAddressesArray.replace('\"', '').split(',', 0);
      }


Email list
[[email protected],[email protected]]

On apex set 
toAddresses:::([[email protected], [email protected]])

Error
failed::SendEmail failed. First exception on row 0; first error: INVALID_EMAIL_ADDRESS,
Email address is invalid: [[email protected]: [toAddresses, [[email protected]]

Emails are valid, when I used a static list it's work perfectly, but it not work with a dynamic list.

static list                
  new List<String>{ '[email protected]' }

1 Answer 1

0

toAddressesArray appears to be a String. As such, you're probably serializing it from JSON. The following should fix the problem:

emails = (String[])JSON.deserialize(toAddressesArray, List<String>.class);

Or, you could change your parameter to be a String[] instead of String, in which case you wouldn't need any further manipulation.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .