I would like to send out an email to the customer automatically every month on the below dates. The day to send out the email will depend on whether it’s a 4- or 5-week month.
4 weeks in a month 17th 1st email and 24th 2nd email
5 weeks in a month 24th 1st email and 31st 2nd email
So, which means
If current month contains 4 weeks(Sunday) and If its contains 28 or 29 (February case)/30/31 days need to send on 17th and 24th
If current month contains 5 weeks(Sunday) and If its contains 31 days need to send on 24th and 31st, other wise 17th and 24th need to send email.
Can some one implement the logic and please help me in this.
Below is the my attempt which I tried:
Integer mnth = Date.Today().month();
Integer date_value = Date.Today().day();
System.debug('*Date*******'+date_value);
System.debug('*Month*******'+mnth);// 1=jan
if(mnth == 2 || mnth == 4 || mnth == 6 || mnth == 9 || mnth == 11){
if(date_value==17){
System.debug('Send 17th date email');
}
if(date_value==24){
System.debug('Send 24th date email');
}
}
if(mnth == 1 || mnth == 3 || mnth == 5 || mnth == 7 || mnth == 8 || mnth == 10 || mnth == 12){
if(date_value==24){
System.debug('Send 24th date email');
}
if(date_value==31){
System.debug('Send 31st date email');
}
}