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
neeruneeru 

Mass Email Limit Exceeds

Hi EveryOne

 

              i am send Emails to My campaignmember contacts..thoe contatcs are totally 32..for tht i wrote batch apex and  scheduled this. it saves but   emails are sent to 1st 10 members only..after i am trying to send emails again it  throws an error in apex jobs(mass email limit exceeds)

 

using batch apex is it possible sent 32 emails at a time??

 

my approch

global class campaignmem implements  Database.Batchable<sobject>,Schedulable {

global final string query= 'select id,campaignid,contactid from campaignmember';   

Private final list<id> Eids=new list<id>();
global campaignmem()
{
   List<Contact> cons  = new List<Contact>();
 
  for(campaignmember cam :[select id,campaignid,contactid from campaignmember])
  {
        if(cam.contactid !=null)
    {
     cons=[select id,name,email from contact where id =:cam.contactid];
     for(Contact c:cons)
     {
       if(c.id!=null)
       {
       Eids.add(c.id);        
       }
     }
     
    }
  }   
   System.debug('--- CampaignMembers ' + query);

}
global void execute(SchedulableContext SC) {
    // invoke business logic - this method is strictly to invoke
    // the method from the scheduler...
   campaignmem CM2 = new campaignmem();
   ID batchprocessid = Database.executeBatch(CM2,10);
   
 }  
global Database.QueryLocator start(Database.BatchableContext BC)
{

   return Database.getQueryLocator(this.query);
}

global void execute(Database.BatchableContext BC, List<campaignmember> scope)
{
    Messaging.MassEmailMessage mail = new Messaging.MassEmailMessage();
       mail.setTargetObjectIds(Eids);
       mail.setTemplateId('00XE0000000s29O');
       Messaging.sendEmail(new Messaging.MassEmailMessage[] { mail });
}
global void finish(Database.BatchableContext BC){

     

}
}

SalmanSalman
Hii neeru ,

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