Sending email from Apex looks very interesting and powerful feature at first glance however by time your application evolves to more complex structure or more data, chances are very high that you will be hitting many Apex email limit related errors. As Salesforce is not mass email sending tool, it makes sense to have limits on total number of outgoing emails per 24 hours.
At a time of writing this post, mainly there would be two types of error while sending email from Apex as explained below
- Transaction based errors
- We can send 100 emails per SingleEmailMessage
- Per day (24 hour) email limit
- We can send 1000 emails per day
One point to note here that we can send unlimited emails to internal users including community users. More details on email limits can be found here (Salesforce governor limits)
I have seen multiple questions on Salesforce developer community on how to resolve error related to sending email per 24 hour in Apex. Below solution has been used by me for a long time and it is working to send thousands of email per day without any problem.
Let’s see how we can resolve this error with below design.