Hello. I want to create a scheduled classin apex on leads which will email me new leads created with their name for every hour . How do i proceed? This is my first time using it. Thank you in advance.
the class name should not be Schedulable. It should be something that explains the purpose of your class. For example EmailLeadScheduler.
but it has to implement Schedulable interface in order for you to be able to schedule it. For example
global class EmailLeadScheduler implements Schedulable {
global void execute(SchedulableContext sc){}
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
}
First create an Apex class that implements Schedulable. Write your logic to send the emails. Once the class is done, go to Setup-> Scheduled Jobs adn set up the interval to be 1 hour.
For more information check out https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_scheduler.htm
For informaiton on sending emails form Apex check out https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_forcecom_email_outbound.htm
In the scheduled jobs lsit you can see all the classes that are already schedule. In order to schedule the new class go through following steps 1. Go to Setup ->Develop->Apex Classes 2. Click Schedule Apex button 3. Select class name, name the scheduled job and specify frequency.
@ Khan thank you sir. The procedure I followed is I created a class named "Schedulable" using develper console and I saved it just as you mentioned. Now when I went to Setup ->Develop->Apex Classes and clicked on Schedule Apex button. An error is popping up stating there are no records of such type. Please see the image below. Do i need to activate any permissions? When I'm clicking on the "Lookyp" for the "ApexClass" it says "No records found of this type".
the class name should not be Schedulable. It should be something that explains the purpose of your class. For example EmailLeadScheduler.
but it has to implement Schedulable interface in order for you to be able to schedule it. For example
global class EmailLeadScheduler implements Schedulable {
global void execute(SchedulableContext sc){}
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
}
Glad it works for you now. I think you chose a wrong best answer. the answer you chose is an inocrrect solution. Please pick n answer with a working solutions, so other users who have the same problem can find it easily
the class name should not be Schedulable. It should be something that explains the purpose of your class. For example EmailLeadScheduler.
but it has to implement Schedulable interface in order for you to be able to schedule it.
For example PS: I am not a man :)
All Answers
Hi Satya,
First create an Apex class that implements Schedulable. Write your logic to send the emails.
Once the class is done, go to Setup-> Scheduled Jobs adn set up the interval to be 1 hour.
For more information check out
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_scheduler.htm
For informaiton on sending emails form Apex check out
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_forcecom_email_outbound.htm
Let me know if oyu have any more questions
global class Schedulable {
global void execute(SchedulableContext sc){}
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
}
I have saved it . What do i do now? I went to Setup>Scheduled jobs it is empty!
In the scheduled jobs lsit you can see all the classes that are already schedule. In order to schedule the new class go through following steps
1. Go to Setup ->Develop->Apex Classes
2. Click Schedule Apex button
3. Select class name, name the scheduled job and specify frequency.
the class name should not be Schedulable. It should be something that explains the purpose of your class. For example EmailLeadScheduler.
but it has to implement Schedulable interface in order for you to be able to schedule it.
For example PS: I am not a man :)
Glad it works for you now. I think you chose a wrong best answer. the answer you chose is an inocrrect solution. Please pick n answer with a working solutions, so other users who have the same problem can find it easily