I have a batch job that emails contacts using a visualforce template. I am using SingleEmailMessage to email contacts as the template pulls data from each contact.
my batch size is 10 and we have about 10k contacts. I noticed SINGLE_EMAIL_LIMIT_EXCEEDED
in the logs and after some investigation, I figured out that there is a governor limit for outbound emails and it is 1000/day.
Trying find a solution for this but ran out of ideas. Would like to know If there is way to email all contacts from a batch job. would appreciate any help and below is the code I am using in the execute method.
EmailTemplate template = [Select id,DeveloperName from EmailTemplate where name= 'UpdateInformation'];
List < Messaging.SingleEmailMessage > msgList = new List < Messaging.SingleEmailMessage > ();
for (Contact contact: (List < Contact > ) records) {
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
email.setTargetObjectId(contact.id);
email.setTemplateId(template.Id);
msgList.add(email);
}
Messaging.sendEmail(msgList);