You need to sign in to do that
Don't have an account?

How to Automate Email So that every day at 10 AM the email should be delivered
Global class TmsEmailDemo { public static void sendEmail() { Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); // Who you are sending the email to List<String> sendTo = new List<String>(); sendTo.add('xyz@gmail.com'); sendTo.add('abc@gmail.com'); mail.setToAddresses(sendTo); System.debug(sendTo); mail.setTargetObjectId('0037F00000FWFGo'); // The email template ID used for the email mail.setTemplateId('00X7F000000pTjc'); //mail.setWhatId(candidate); mail.setBccSender(false); mail.setUseSignature(false); mail.setReplyTo('cvb@gmail.com'); mail.setSenderDisplayName('Ajay'); mail.setSaveAsActivity(false); Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail }); } }HI can anyone help me on how to Automate Email So that every day at 10 AM the email should be delivered.
Thanks in advance
To schedule your apex, you need to perform below steps:
- Implement the Schedulable interface in an Apex class that instantiates the class you want to run.
- From Setup, enter Apex Classes in the Quick Find box, select Apex Classes, and then click Schedule Apex.
- Specify the name of a class that you want to schedule.
- Specify how often the Apex class is to run.
- For Weekly—specify one or more days of the week the job is to run (such as Monday and Wednesday).
- For Monthly—specify either the date the job is to run or the day (such as the second Saturday of every month.)
- Specify the start and end dates for the Apex scheduled class. If you specify a single day, the job only runs once.
- Specify a preferred start time. The exact time the job starts depends on service availability.
- Click Save.
Below are some helpful links:https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_scheduler.htm
https://salesforce.stackexchange.com/questions/137323/schedule-messaging-sendemail
Please mark the answer as best if this helps
Thanks,
Aman
All Answers
To schedule your apex, you need to perform below steps:
- Implement the Schedulable interface in an Apex class that instantiates the class you want to run.
- From Setup, enter Apex Classes in the Quick Find box, select Apex Classes, and then click Schedule Apex.
- Specify the name of a class that you want to schedule.
- Specify how often the Apex class is to run.
- For Weekly—specify one or more days of the week the job is to run (such as Monday and Wednesday).
- For Monthly—specify either the date the job is to run or the day (such as the second Saturday of every month.)
- Specify the start and end dates for the Apex scheduled class. If you specify a single day, the job only runs once.
- Specify a preferred start time. The exact time the job starts depends on service availability.
- Click Save.
Below are some helpful links:https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_scheduler.htm
https://salesforce.stackexchange.com/questions/137323/schedule-messaging-sendemail
Please mark the answer as best if this helps
Thanks,
Aman
Thanks for the supoort...I followed your steps its working well.
But the problem is with my email template...It is only showing one name because of my email template.
Can you help me to give different name for different email id.
Below is my emale template snipp.
You are using {!Contact.Nam} in your template, even thouth you are getting same name for every contact?
Kindly put more light on this.
Thanks,
Aman