I've a requirement to send single email messages to external users and I wrote apex class to achieve this.We send upto 80 mails per day,eventhough I'm getting email limit exceeded error.Please help me to resolve this?
-
We are on Unlimited edition.We get 1000 emails per a day,but getting above error by sending 80 emails.Do you think I made wrong coding in apex code or is it suggested to user @future ?– User1511Commented Sep 30, 2015 at 20:56
-
What COUNTS towards the limit * Mass Emails to Contacts * Mass Email to Leads * Emails send via the API to email addresses * Emails send via the API to contacts (Both single and mass emails) * Emails send via API to Leads (both Single & Mass Emails) What DOES NOT COUNT towards the limit * Mass emails to Users * Emails via API to User ID’s * Emails send from the “Send Email” button on contacts (single emails/email author) * Emails send from the “Send Email” button on Leads (single emails/email author) * Workflow emails * System generated emails– DJDCommented Sep 30, 2015 at 21:24
3 Answers
I highly recommend, where possible, that instead of using Apex outbound email, that you set a boolean field on the target object indicating it is "ready for email to be sent" and then have a workflow that uses that boolean as the criteria + two actions:
- Email alert
- Field Update to reset the boolean to false
There is no 1000 emails per day limit when using Workflow (or Process Builder) - triggered email alerts
In addition, best practice in Apex outbound email is to use the method reserveSingleEmailCapacity
to see if you have enough headroom to send the message, and if, not, continue and notify the user to wait until the next day, with suitable retry mechanism.
What COUNTS towards the limit * Mass Emails to Contacts * Mass Email to Leads * Emails send via the API to email addresses * Emails send via the API to contacts (Both single and mass emails) * Emails send via API to Leads (both Single & Mass Emails)
What DOES NOT COUNT towards the limit * Mass emails to Users * Emails via API to User ID’s * Emails send from the “Send Email” button on contacts (single emails/email author) * Emails send from the “Send Email” button on Leads (single emails/email author) * Workflow emails * System generated emails
-
Here's the link for salesforce limits reference. Hope this helps. (login.salesforce.com/help/pdfs/en/…)– DJDCommented Sep 30, 2015 at 21:25
-
In addition, email sent to User ID's via code (not workflow) count against the limit able to be sent to external addresses (even though UserIDs are not stopped by the 1000 limit) So if you send to 999 UserIDs you can only send to one email address (At least it used to and was not documented as such, have not tested in a while). Note: External Address is defined as ANY email address ([email protected] for example) even if it is a users email– EricCommented Sep 30, 2015 at 23:30
You can check the limit and usage with Salesforce Workbench. Please follow this link to get the detail steps. You can check the usage at different time to see where you hit the limit. Hope this will help.