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
VRKVRK 

Error Occurred: An Apex error occurred: System.EmailException: SendEmail failed. First exception on row 0; first error: INVALID_EMAIL_ADDRESS, Email address is invalid: null: [toAddresses, null]

When i execute this code getting below error , pls check and let me know if i did anything wrong in my code below  :
Error Occurred: An Apex error occurred: System.EmailException: SendEmail failed. First exception on row 0; first error: INVALID_EMAIL_ADDRESS, Email address is invalid: null: [toAddresses, null]
I verified, Email address already exists for 'Approver_email__c' ...But not sure , why this error coming ....any ideas and let me know is anything wrong on my code 
******************************************************************
    public class EmailNotification {
    public string toAddress{get;set;}
    public string message{get;set;}
@InvocableMethod  
        public static void sendingEmail(){
       Level_Agreement__c sla = new Level_Agreement__c();  
        Case c = new Case();    
          if(c.Task_Category__c == sla.Task_Category__c) 
          {
           Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage();     
            String[] toAddresses =new List<String>{sla.Approver_email__c};
            semail.setToAddresses(toAddresses);
           semail.setSubject('Testing email through apex');
           semail.setBccSender(false);
           semail.setUseSignature(true);
           semail.setPlainTextBody('Dear User, Request for Process Reviewer notification mail ');   
           Messaging.sendEmail(new Messaging.SingleEmailMessage[] { semail });   
              
          }
          
           }        
      
   
    }
 pls let me know if i did any wrong in the code .......Thanks 
Sekhar
Soyab HussainSoyab Hussain
Hi Sekhar,

Try this code I think this will help you.
 
public class EmailNotification {
 public string toAddress {get;set;}
 public string message {get;set;}
 @InvocableMethod
 public static void sendingEmail() {
  Level_Agreement__c sla = new Level_Agreement__c();
  Case c = new Case();
  if (c.Task_Category__c == sla.Task_Category__c) {
   Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage();
   String[] toAddresses = new List < String > {sla.Approver_email__c};
   System.debug('toAddresses ' + toAddresses ); //I thing here you are getting blank list let check
   if (!toAddresses.isEmpty()) {
    semail.setToAddresses(toAddresses);
    semail.setSubject('Testing email through apex');
    semail.setBccSender(false);
    semail.setUseSignature(true);
    semail.setPlainTextBody('Dear User, Request for Process Reviewer notification mail ');
    Messaging.sendEmail(new Messaging.SingleEmailMessage[] {semail});
   }


  }

 }


}

Regards,
oyab
Soyab HussainSoyab Hussain
Regards,
Soyab