You need to sign in to do that
Don't have an account?
Rakesh S
Schedulable class for sending an email
Hi All,
Written a schedulable class for sending an email on every wednesday.
My schedulable class:
Let me know what is the wrong in this and give me solution.
Thank you...
Written a schedulable class for sending an email on every wednesday.
My schedulable class:
global class ClassEmailSchedule implements Schedulable { public List<Log_Book__c> lb{get;set;} global void execute(SchedulableContext SC){ sendMail(); } public void sendMail(){ lb = [SELECT ID, NAME, Subject__c, Student__r.NAME,Class_Scheduled_Date__c, Student__r.Parent_Email__c, Subjects_Registered__r.Select_Day__c FROM Log_Book__c WHERE Subjects_Registered__r.Select_Day__c = 'Wednesday' ]; for(Log_Book__c email : lb){ if(email.Class_Scheduled_Date__c == Date.today()){ List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>(); Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); List<String> sendTo = new List<String>(); sendTo.add(email.Student__r.Parent_Email__c); mail.setToAddresses(sendTo); mail.setReplyTo('bhaskar.thamma@gmail.com'); mail.setSenderDisplayName('BHASKAR'); // (Optional) Set list of people who should be CC'ed List<String> ccTo = new List<String>(); ccTo.add('jagadeesh.adaveni@gmail.com'); mail.setCcAddresses(ccTo); mail.setSubject('Reminder for Class'); String body = 'Dear <b>' + email.Student__r.name + '</b>, '; body += 'Your class is to day at 10.00 AM.'; body += 'Thank you...'; mail.setHtmlBody(body); mail.saveAsActivity = false; mail.setTargetObjectId(email.Id); mails.add(mail); // Step 5. Add your email to the master list Messaging.sendEmail(mails); } } } }Class scheduled but not getting any email.
Let me know what is the wrong in this and give me solution.
Thank you...
Code looks fine to me. Have you checked with Email Deliverability?
You can find it here: Setup->Administer->Email Administration->Deliverability.
Select Access Levels as 'All Emails'.
It should work now.
Regards,
Sandeep Mishra