+ Start a Discussion
nikita dhamalnikita dhamal 

Error :Mass Email Limit Exceeded

I have used the mass email functionality  in my code but after sending emails 10 times jus to single person or 2 at a time i got the following error:
Visualforce Error
Help for this Page
System.EmailException: SendEmail failed. First exception on row 0; first error: MASS_MAIL_LIMIT_EXCEEDED, Email limit exceeded: []
Error is in expression '{!processSelected}' in component <apex:commandButton> in page sendmail: Class.ContactSelectClassController.processSelected: line 81, column 1
Class.ContactSelectClassController.processSelected: line 81, column 1
I am pasting  my code below:
Visualforcepage:
apex:pageBlock >
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton value="Send Email" action="{!processSelected}" styleClass="sendemail" rerender="table2"/>
            </apex:pageBlockButtons>
 
            <apex:pageblockSection title="All Contacts" collapsible="false">
 
             <apex:pageBlockTable value="{!wrapAccountList}" var="accWrap" id="table">
                    <apex:column >
                        <apex:facet name="header">
                            <apex:inputCheckbox onclick="selectAllCheckboxes(this,'inputId')"/>
                        </apex:facet>
                        <apex:inputCheckbox value="{!accWrap.selected}" id="inputId"/>
                    </apex:column>
                    <apex:column value="{!accWrap.acc.Name}" />
                    <apex:column value="{!accWrap.acc.Email}" />
                    <apex:column value="{!accWrap.acc.Phone}" />
                </apex:pageBlockTable>
 
               <apex:pageBlockTable value="{!selectedAccounts}" var="c" id="table2" title="Selected Accounts">
                   <apex:column value="{!c.Id}" headerValue="Contact"/>
                    <apex:column value="{!c.Name}" headerValue="Contact Name"/>
                    <apex:column value="{!c.Email}" headerValue="Email"/>
                    <apex:column value="{!c.Phone}" headerValue="Phone"/>
                    
                </apex:pageBlockTable>
 
            </apex:pageblockSection>
            
        </apex:pageBlock> 
Controller:
public class ContactSelectClassController{
 
   
    public List<wrapAccount> wrapAccountList {get; set;}
    public List<Contact> selectedAccounts{get;set;}
    public String feedid;
    private  List<Id> contactids=new list<Id>();
    public List<Contact> conts;
   
    public List<Feedback_Contacts__c> feedcon{get;set;} 
    public ContactSelectClassController()
    {
     feedid= (ApexPages.currentPage().getParameters().get('fid'));
    system.debug('*********************Feedback id is :*********************************'+feedid);
     system.debug('*********************contactidscontactidscontactids:*********************************'+selectedAccounts);
           
        if(wrapAccountList == null)
         {
            wrapAccountList = new List<wrapAccount>();
            for(Contact a: [select Id, Name,Email,Phone from Contact])
             {
                wrapAccountList.add(new wrapAccount(a));
             }
         }
     }
   public pageReference CancelAction()
  {
    PageReference pr1 = new PageReference('/apex/LaunchPage');
   
    pr1.setRedirect(false);
    return pr1;
  } 

    public void processSelected()
     {
     
     feedid= (ApexPages.currentPage().getParameters().get('fid'));
     
       system.debug('*********************Feedback id feedidfeedid :*********************************'+feedid);
        system.debug('*********************contactidscontactidscontactids:*********************************'+selectedAccounts);
           
    selectedAccounts = new List<Contact>();
 
        for(wrapAccount wrapAccountObj : wrapAccountList)
         {
            if(wrapAccountObj.selected == true)
             {
                selectedAccounts.add(wrapAccountObj.acc);
                 system.debug('*********************contactidscontactidscontactids:*********************************'+selectedAccounts);
           
             }
         }
         system.debug('*********************selectedAccountsselectedAccountsselectedAccounts*********************************'+selectedAccounts);
           
          for(Contact cont: selectedAccounts)
        {
           system.debug('*********************contactidscontactidscontactids:*********************************'+contactids);
            contactids.add(cont.Id);
            system.debug('*********************contactidscontactidscontactids:*********************************'+contactids);
        } 
        feedcon=new List<Feedback_Contacts__c>();
        for(Contact cont: selectedAccounts)
        {
        Feedback_Contacts__c fc=new Feedback_Contacts__c();
        fc.FeedbackContactName__c=cont.Id;
        fc.FeedBackNo__c='a0036000005RaG0';
        
        feedcon.add(fc);
        insert fc;
        // feedcon.add(cont.Id);
        // feedcon.add('a0036000005RaG0');
         
        } 
        
        Messaging.MassEmailMessage mail = new Messaging.MassEmailMessage();
      system.debug('*********************selectedAccountsselectedAccountsselectedAccounts*********************************'+selectedAccounts);
   // system.debug('*********************s*********************************'+);
              
        mail.setTargetObjectIds(contactids);
        mail.setTemplateId('00X360000015j6P');
        Messaging.sendEmail(new Messaging.MassEmailMessage[] { mail });
     }
 
    public class wrapAccount {
        public Contact acc {get; set;}
        public Boolean selected {get; set;}
 
        public wrapAccount(Contact a) {
            acc = a;
            selected = false;
        }
    }
}

How will i be able to get the limit for my org 
SalmanSalman
Hii nikita dhamal ,

can you please check this app for avoiding  email limit in Salesforce
 
MassMailer lets you send unlimited emails from within Salesforce, no matter which edition you use. Built on the Salesforce platform, it has all the mass email features you’ll ever need.Build, send, and schedule professional-looking emails with a simple to use email Wizard within Salesforce – no HTML experience required.

You can try this app by installing from appexchange- MassMailer 

For Developer's Guide please click here-Developer's Guide

You can learn more details about the product on this website -Link