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
Mayank07Mayank07 

ServiceRequestEmail: execution of AfterUpdate caused by: System.EmailException: SendEmail failed. First exception on row 0; first error: SINGLE_EMAIL_LIMIT_EXCEEDED, Email limit exceeded: [] Trigger.ServiceRequestEmail: line 31, column 1

Guys Please help why i am getting this error when i am firing the trigger.. and what's the possible work around? here's my code
trigger ServiceRequestEmail on Service_Request__c (after update) {
    
 /*   List<Id> sRequest = new List<Id>();
    for(Service_Request__c  i:trigger.new) {
        sRequest.add(i.Id);
}
   List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
                for(Service_Request__c sR : Trigger.new){
                if(sR.Status__c == 'Closed' && sR.Customer_Email__c !=null){
                Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                List<String> sendTo = new List<String>();
                sendTo.add(sR.Customer_Email__c);
                mail.setToAddresses(sendTo); 
                mail.setReplyTo('think4u007@gmail.com');
                mail.setSenderDisplayName('ASD Servicing Company');
                List<String> ccTo = new List<String>();
                ccTo.add('mayanktripathi201194@gmail.com');
                mail.setCcAddresses(ccTo);
                mail.setSubject('Billing Deatils for the Servicing with ASD Company ');
                String body = '<html><body>Dear ' + sR.Name + ' It was a pleause to assist you with your Vehicle servicing.<br><br>Below are the details of Your biliing : <br> Oil Check & Touchup Cost: ' + sR.Oil_Checks_Touchup_Cost__c + ' <br> Total External Repair Cost: ' + sR.Total_External_Repair_Cost__c + ' <br> Total Interior Repair Cost: ' + sR.Total_Internal_Repair_Cost__c + ' <br> Effort Required by the Serviceman: ' + sR.Total_Effort_Required__c + ' <br> Overall Vehicle Servicing Cost: ' + sR.Total_Repair_Cost__c + ' <br> Thanks for Visiting us. <br><br>Have a Nice Day!</body></html>';
                mail.setHtmlBody(body);
                mails.add(mail);
   }          
  } 
               
  
       Messaging.sendEmail(mails); 


}

 
Agustin BAgustin B
Hi, you exceeded the single email limits, check this for reference
https://help.salesforce.com/articleView?id=000323568&language=en_US&type=1&mode=1
If it helps,please mark as correct it may help others.
VinayVinay (Salesforce Developers) 
Hi Mayank,

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

Review below links for more information.

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_gov_limits.htm
https://help.salesforce.com/articleView?id=000331939&language=en_US&type=1&mode=1

Hope above information was helpful.

Please mark as Best Answer so that it can help others in the future.

Thanks,
Vinay Kumar
Mayank07Mayank07
but today i could send only 5-6 emails and it started showing me this error, maybe it's running in loop and trying to send emails on all the records who matches with the condition. i want to send messages only when a record gets updated
 
VinayVinay (Salesforce Developers) 
Hi Mayank,

You can check the email logs.

Email Logs:

Quick Find >> Email Log Files >> >> Click Request an Email Log.

However, the above error says about hitting governor limits.

Thanks,
Vinay Kumar