1

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);
1
  • why don't you try WF email alert. – Tushar Sharma Jan 26 '16 at 5:29
0

As per the documentation you can send mass email to a maximum of 1,000 external email addresses per day per organization based on Greenwich Mean Time (GMT). The maximum number of external addresses you can include in each mass email depends on your edition

enter image description here

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_gov_limits.htm#email_limits_section

2
  • @Himasnshu, Thanks and That is what I read earlier I am looking for a solution If possible. – sdondeti Jan 25 '16 at 18:15
  • Use ExactTarget or Silverpop if you need more than 1000. – Himanshu Jan 25 '16 at 18:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.