SINGLE_EMAIL_LIMIT_EXCEEDED. What does it mean?

  • What does the exception mean? It does not seem to be related to the Number of email invocations limit because of the following line at the end of the log: Number of Email Invocations: 5 out of 10

    I also check the email limits before sending an email:

    Integer used = Limits.getEmailInvocations();
    Integer emailLimit = Limits.getLimitEmailInvocations();
    if(used >= emailLimit){
        //print email text instead of email it.
    
    }
    else{
        //send email
    }
    

    Any clarification on this exception would be much appreciated. Thanks!

    Are you working in a developer edition org? i believe these have lower daily limits (around 10 emails per day).

    The Limits Static Methods are *per transaction limits*, and do not divulge *per organization* limits. For example, `getLimitFutureCalls` tells you nothing of the organization's daily future call limit (250k or licenses * 200, whichever is greater). Instead, you will know how many more future calls you can execute before your transaction fails.

    I am working in a developer edition org.

  • Per the Governor Limits, you can only send 5000 single emails a day (or less, depending on license).

    Using the API or Apex, you can send single emails to a maximum of 5,000 external email addresses per day based on Greenwich Mean Time (GMT). Single emails sent using the Salesforce application don't count toward this limit. There’s no limit on sending individual emails to contacts, leads, person accounts, and users in your organization directly from account, contact, lead, opportunity, case, campaign, or custom object pages.

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

    As a side note, you can gracefully catch the error with Messaging.reserveMassEmailCapacity and Messaging.reserveSingleEmailCapacity, which lets you catch exceptions when your organization would be exceeded. You can either back off the number sent, or inform the user that there are insufficient messages remaining.

    Looks like I will have to wait until tomorrow and see if that is the issue. (I have a sneaking suspicion that it is.) In the mean time, I will add that exception handling.

    Email is working now. Looks like I hit a daily org limit.

    Messaging.reserveSingleEMailCapacity() didn't seem to work. It was not throwing an exception when I called it.

License under CC-BY-SA with attribution


Content dated before 7/24/2021 11:53 AM