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
Pramodh_ShivaPramodh_Shiva 

SINGLE_EMAIL_LIMIT_EXCEEDED

Hi All,

so I am facing quite strange error in email and I tried all possible ways from 3 days and I couldn't figure out why am getting this SINGLE_EMAIL_LIMIT_EXCEEDED.

In contact list view I have a custom button called mass mail which calls VF page where I will select the template and click send button.
in controller there's an sendmail method which will divide the list of contact's into 2 arrays and send mail using single email class twice (becoz we need to remove 'via') everything was working fine until in a particular list view where lets say XYZ if i select more than 50 contacts and send mail it is throwing SINGLE_EMAIL_LIMIT_EXCEEDED error. apart from XYZ list view if I select any other list view everything is working fine even for 200 records (i.e 200 mails are sent) so i modified my code and divided the list into 4 different arrays and sending mail 4 times (as limit for email invocation is 10) again this function is working for all list view except XYZ list view.

additional info:
max i will select 200 and dividing into 4 so each sendmail will have only 50 recipients.(limit is 100 recipients) 
no cc and bcc.
Gokula KrishnanGokula Krishnan

Hi Pramodh,

Check whether you have invoke the Messaging.sendEmail call inside the loop. If it so you will get error, place it out side the loop(it may also cause if you call the Method inside loop, call method contains the sendEmail code). 

My suggestion, there is no need to split into 4 arrays values. You can send in one shot.

Reference:
https://salesforce.stackexchange.com/questions/25184/single-email-limit-exceeded-what-does-it-mean
https://www.soliantconsulting.com/blog/2009/07/how-to-avoid-governor-limits-with-sendemail-in-apex


Thanks,

If it helps you, please mark is as best answer, so it will be helpful for other developers.