+ Start a Discussion
smitha vikramsmitha vikram 

Send email from batch class every 4 days from start date till case created

I have written a batch class that updates some date fields on the account. When one of the date field on the account date1 is equal to today , not only do i have to send an email, but i should send an email every 4 days starting from due date till a case is created for that account.  A case gets created for an account via forum assmebly and that flags the value on the account. How can i approach this. Hopefully someone can help.
this is the part of cod in batch that adds accounts to list to whom a mail is sent

            if(theAccount.RocketPro_Renewal_Status__c == Label.RenewalStatus_NeedsRenewal && theAccount.RocketPro_isRenewal_Required__c==true){
            if(theAccount.RocketPro_Next_Renewal_Date__c == System.today()){
                theAccount.RocketPro_Renewal_Status__c == Label.RenewalStatus_NeedsRenewal;
                Label.RenewalStatus_NeedsRenewal&&theAccount.RocketPro_isRenewal_Required__c = true;
ANUTEJANUTEJ (Salesforce Developers) 
Hi Smitha,

Although there could be different ways to implement this one way that I could think of is to have a naxtdate field which has a date value of on what dates the email needs to be sent and while retrieving the records you can choose write the soql where the nextdate field has that dates value.

Also if the due date is less than 4 days then the nextdate would be that due date.

Let me know if this helps.

smitha vikramsmitha vikram
So will i write the schedule Apex, one for the batch to run overnight, one to send an email at 2 pm next day and one for email obe sent Tuesday after due date?