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
k sfdck sfdc 

URGENT:How to solve below Batch class Error(MASS_MAIL_LIMIT_EXCEEDED, Failed to send email) ?

First error: SendEmail failed. First exception on row 1; first error: MASS_MAIL_LIMIT_EXCEEDED, Failed to send email

Batch class:

global class MyBatchClass implements Database.Batchable<sObject>   {     global Database.QueryLocator start(Database.BatchableContext bc)     {     
   Date d=;        
 String soqlQuery = 'SELECT id,name,Owner.Email,Owner.Name,Expiry_Date__c FROM Account WHERE Expiry_Date__c < :d';         return Database.getQueryLocator(soqlQuery);   
  global void execute(Database.BatchableContext bc, List<Account> accountList)
      List<Messaging.SingleEmailMessage> mailList = new List<Messaging.SingleEmailMessage>();
        for(Account acc: accountList)  
      List<String> toAddresses = new List<String>();      
       Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
      mail.setSubject('Welcome to Sweet 16 Siebel Batch');
     String messageBody = '<html><body>Hi ' + acc.Name + ',<br>Your account Expires today. <br>Kindly contact your administrator.<br><br><b>Regards,</b><br>Mahesh k</body></html>';         
  global void finish(Database.BatchableContext bc)     {     } }
Schedule Class:

global class ScheduleBatchClassForSendEmail implements Schedulable{       
 global void execute(SchedulableContext sc) {
         MyBatchClass schedulejob = new  MyBatchClass();        
   database.executebatch(schedulejob);      }  }

SonamSonam (Salesforce Developers) 
You are hitting the daily mass email limit which is the reason you are seeing this error:
Mass email messages sent with the sendEmail method count against the sending organization's daily mass email limit. When this limit is reached, calls to the sendEmail method using MassEmailMessage are rejected, and the user receives a MASS_MAIL_LIMIT_EXCEEDED error code.

If you wish to know in advance as to whether this limit will be it or not - try the option given in the below thread: