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 

System.EmailException: SendEmail failed. First exception on row 0; first error: SINGLE_EMAIL_LIMIT_EXCEEDED, Email limit exceeded: []

can anyone please tell me how to fix the issue.
my Apex method is
public class ServiceRequestEmailHandler {
  public static void sendSingleEmail(List<Id> RecordId){
                List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
                for(integer i=0; i<RecordId.size(); i++) {
                for(Service_Request__c sR : [Select id, Name, Status__c, Customer_Email__c, Oil_Checks_Touchup_Cost__c, Total_External_Repair_Cost__c, Total_Internal_Repair_Cost__c, Total_Effort_Required__c, Total_Repair_Cost__c FROM Service_Request__c  WHERE Id = :RecordId[i] ]){
                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);
} 
}

And my trigger is
trigger ServiceRequestEmail on Service_Request__c (after update) {
    
    List<Id> sRequest = new List<Id>();
    for(Service_Request__c  i:trigger.new) {
        sRequest.add(i.RecordTypeId);
}
    ServiceRequestEmailHandler.sendSingleEmail(sRequest); 
}

​​​​​​​
{tushar-sharma}{tushar-sharma}
This is something not related to your code instead its related to your org. In developer org its 15 while in live org its 5000. You need to wait for 24 hours to get this limit reset.

Single email daily limits for messages sent using API methods (https://help.salesforce.com/articleView?id=000323568&language=en_US&type=1&mode=1)

If this answer helps you, please mark it as accepted.

Regards,
Tushar Sharma
https://newstechnologystuff.com/
Mayank07Mayank07
But i have seen people send more than 500 emails in one day with the developer org only, i think i am facing this issue because the code is running in loop, can you figure out how to run it for each time only for one record?
 
firdoss mohd 1firdoss mohd 1
Hi Mayank,

It looks like our team of experts can help you resolve this ticket. We have Salesforce global help-desk support and you can log a case and our Customer Success Agents will help you solve this issue. You can also speak to them on live chat. Click on the below link to contact our help-desk. Trust me it is a support service that we are offering for free!

https://jbshelpdesk.secure.force.com

Thanks,
Jarvis SFDC team