+ Start a Discussion
venkateshyadav1243venkateshyadav1243 

SINGLE_EMAIL_LIMIT_EXCEEDED

Hi

Am getting this error SINGLE_EMAIL_LIMIT_EXCEEDED after sending 7 emails.

 

this my code can any one tell me where am missing.

its shwoing error on this line :Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

 

my code:

public with sharing class ctrlSendMailWithAttachmentg
{

    public String emailBody { get; set; }
    public String backURL{ get; set; }
    public String emailSubject { get; set; }

    //public ID parentId {get;set;}
    public String email { get; set; }
    public SFDC_Salary_History__c cRObj{get;set;}
    public Task task{get;set;}
    String emailId;
    public string clientEmail{get;set;}
    public string msg{get;set;}
    public Id parentId ;
   
    public ctrlSendMailWithAttachmentg()
    {
        cRObj = new SFDC_Salary_History__c();
        emailId = System.currentPagereference().getParameters().get('EmailId');
        
        email = emailId ;
        parentId = System.currentPagereference().getParameters().get('Id');        
        cRObj= [select  Employee_Email__c , id, name, Employee__r.id, Employee__r.name, Employee__r.Email_Address__c, Month__c,Year__c from SFDC_Salary_History__c where id=:parentId ];
         clientEmail=cRObj.Employee_Email__c ;
       
         system.debug('------20-------'+parentId );
         try
         {
            
            backURL='/'+parentId;
             
        }
        Catch(Exception ex)
        {
        }
         string cusname= cRObj.Employee__r.name;
            emailSubject='Payslip for '+cRObj.Month__c+', '+cRObj.Year__c;
            emailBody='Dear ' + cusname +', <br> <br>'+'Please find the attached Payslip of'+' '+cRObj.Month__c+','+cRObj.Year__c+'. If you have any additional questions, feel free to contact me directly.\n\n';
           
        
    }
public PageReference sendPdf()
    {
      
       
         Id parentId = System.currentPagereference().getParameters().get('Id');
         system.debug('------43-------'+parentId);
         
        
          if(clientEmail==null || clientEmail=='')
          {
                 ApexPages.addmessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Please enter an email id in To field first'));
                 return null;
          }
           else
           {
             system.debug('------Client email id-------'+clientEmail);
                   
                PageReference pdf = Page.salarypage;
                pdf.getParameters().put('id',parentId);
                pdf.setRedirect(true);
                // the contents of the attachment from the pdf
                Blob body;
         
                try
                {
                  // returns the output of the page as a PDF
                  body = pdf.getContent();
                }
                catch (VisualforceException e)
                 {
                      body = Blob.valueOf('Internal Processing Error, Please Contact System Admin');
                 }
            
         //-----------------------------------------------------------------------------------------
                
                Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
                attach.setContentType('application/pdf');
                attach.setFileName('Salary Slip');
                attach.setInline(false);
                attach.Body = body;
                
                List<Messaging.Emailfileattachment> efaList = new List<Messaging.Emailfileattachment>();
                efaList.add( attach );
                
                                String[] ccAddresses = new String[] {'xxx@gmail.com'};

              
                Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                mail.setUseSignature(false);
                mail.setToAddresses(new String[] { clientEmail  });
                mail.setCcAddresses(ccAddresses);
                mail.setSubject(emailSubject);
                mail.setHtmlBody(emailBody);
               
                mail.setFileAttachments(efaList );
             
            // Send the email
                Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
         
                ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO, 'Email with PDF sent to '+email));
         
                return new PageReference('/'+parentId);
         }
  }

    
 

}

Vinita_SFDCVinita_SFDC

Hello,

 

It is the number of email can be sent per day per Org. For details please refer following help document:

 

https://help.salesforce.com/apex/HTViewSolution?urlname=What-are-Single-Email-Limits-Can-a-customer-check-his-balance-for-the-day-1327107568013&language=en_US

mahimmahim