8

I was recently trying to answer a question about email limits. I remember there being a cap on the number of emails sent per invocation (100), but I couldn't find any documentation that still mentions that limit. Has it been lifted?

1 Answer 1

7

The limit seems to have gone. This works in my developer org:

Messaging.SingleEmailMessage[] messages = new Messaging.SingleEmailMessage[0];
while(messages.size()<1000) {
    Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
    message.setTargetObjectId(UserInfo.getUserId());
    message.setSubject('Email Run: '+(1+messages.size()));
    message.setPlainTextBody('This is message '+(1+messages.size())+' of 1000.');
    message.setSaveAsActivity(false);
    messages.add(message);
}
Messaging.sendEmail(messages);

(I'm now waiting for 1000 messages in my inbox...)

Of course, normal CPU limits apply, and this code takes about 1500 ms.

Edit: 10000 emails also worked, but I was smart enough to use System.assert(false) to prevent my inbox from being flooded for the next few days...

4
  • 2
    @AdrianLarson I'm behind on my release notes, but I'm pretty sure we should have seen this somewhere.
    – sfdcfox
    Commented Aug 17, 2016 at 16:04
  • 1
    @AdrianLarson I just tested 10,000 messages in the code, followed by 11,000 messages... This is going to clear up some of that funky code I had to use before.
    – sfdcfox
    Commented Aug 17, 2016 at 16:10
  • Not that your daily limits will allow that unless you send them all to a User. Or did those limits change too?
    – Adrian Larson
    Commented Aug 17, 2016 at 16:14
  • 1
    @AdrianLarson No, the other limits still apply; 1k external emails per 24 hours, and 100 external emails per SingleEmailMessage.
    – sfdcfox
    Commented Aug 17, 2016 at 16:16

You must log in to answer this question.

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