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

System.LimitException: Too many Email Invocations: 11

I'm having trouble with this because the documentation says that the limit is number of sendEmail methods called, but my trigger is bulkified and the method is only called once.


Does this error mean that you can only send 10 emails per apex execution?  That sounds nutso.  Here's the code (note: accountIds set was already populated)


// Email related vars

Messaging.SingleEmailMessage m;

string messageBody;

Messaging.SingleEmailMessage[] emails = new List<Messaging.SingleEmailMessage>();


Account[] accounts = [select id, name, ownerid,, type from Account where id in :accountIds];

for(Account a : accounts)


 if(a.type.startsWith('X') || a.type.startsWith('Pending')) { 

  messageBody = 'The account: "' + + '" with type ' + a.type + ' has closed an opportunity';

  m = new Messaging.SingleEmailMessage();



  m.setSubject('Pending or X account ' + + ' has closed an opportunity');

  m.setToAddresses(new list<string>{});




 if(a.type == 'Distributor' || a.type == 'Distributor & Customer') {

  a.type = 'Distributor & Customer';

 } else if(a.type == 'Prospect' || a.type == 'Customer' || a.type == 'X Customer') {

  a.type = 'Customer';

 } elseif(a.type == 'CP: Consultant') {

  a.type = 'CP: Consultant & Customer';

 } else {

  a.type = 'Partner & Customer';




update accounts;




Does anybody know the real answer?


It looks like you did this right. The limit is invocations of the sendEmail Method, not the number of emails sent (there are different limits for that)


Is it possible the trigger is being run multiple times?  Try adding something like this before the sendEmail function and reviewing the debug logs to see what is going on:


system.debug('@DEBUG: Email invocation count: ' + Limits.GetEmailInvocations());

Is this trigger on account object? If yes, then same trigger will invoked multiple time as you're updating the account object.