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
Ankit Agarwal 74Ankit Agarwal 74 

Send mass email

Hi all,

I want to send mass email but the mail have 5 different kind of mail instance so can you guys help me how to achieve this.

Below is the code that I have written in my code:
 Messaging.sendEmail(new Messaging.MassEmailMessage[] { mail1,mail2,mail3,mail4,mail5 });

where 
 Messaging.MassEmailMessage mail1 = new Messaging.MassEmailMessage();
and so on...

In the current scenario if there is data in mail1 till mail5 then emails are send successfully but if any one of the instance is null, email is not send.

Can any one please help in correcting my code so that the emails are send successfully irrespective of null instance.