I am working on sending mails to 50 clients at one go( basically at lead genration). I was able to send 11 mails until I used static body through SetHtmlBody() of my Batch class having Database methods. But the problem arises when I have to choose the template dynamically as we have a form having radio buttons. Now the same error is coming: Too many email invocations : 11.

Please help me to sort this error.

  • 1
    Can you show the source code with your invocation? Messaging.sendEmailMessage takes a list. It's usually possible to assemble multiple emails, but send them all in one invocation. Jan 18, 2013 at 13:09

2 Answers 2


As per the documentation re governor limits, you can only actually call the sendEmail method of the Messaging class 10 times.


You are receiving this message because you will have called it 11 times in the same context. Depending on your use case, there are a couple of ways to circumnavigate this. If you really do need to call the sendEmail method more than 10 times, you could use a Batch Apex class and set your batch size to 1 (to 10 depending how you implement it). This would allow you to call the method 10 times per execute iteration. See this blog entry for details:


Its not clear from your post whether that is what you want to do, but you can also send the same email to multiple addresses using the following format:

setToAddresses( new String[] {address1, address2, address3} )

Or, different emails to different addresses using something like:

List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
// add mails to list here
Messaging.sendEmail( mails );

See the documentation here:



I have an answer on how to do this already on a similar question: https://salesforce.stackexchange.com/a/3999/60

In summary, Messaging.sendEmail accepts a List, which means each call to it can include a large number of emails to send - you need to bulkify your send email calls just like you would in an apex trigger.

  • lol, I was on holiday when you did that one, that's my excuse and i'm sticking to it ;) Jan 18, 2013 at 19:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .