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
Bryan TelfordBryan Telford 

Apex email error

Hello! I'm trying to send an email through Apex. Can anyone help me understand why the following code results in this error?
SendEmail failed. First exception on row 0; first error: INVALID_EMAIL_ADDRESS, Email address is invalid: : [toAddresses, ]

Code is below
            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();                           
            String sendEmailsTo = qcRequest.To_Emails__c;        
            String[] toAddresses = sendEmailsTo.split(';');
            System.debug('Emails: ' + toAddresses);
Thanks for any help you can provide!
Prateek Singh SengarPrateek Singh Sengar
Hi Bryan,
What is the output of the debug statement? That output might help us in finding the issue
Bryan TelfordBryan Telford
I figured out the problem.sendEmails was getting set to null, thus toAddresses was null as well.