You need to sign in to do that
Don't have an account?
Rakesh S
Send email every day 4 PM
Hi All,
i want to send email every day 4 pm. for that i written some code.
Please check it below code once and let me know, what i have to do.
Please explain step by step.
I appriciate your response.
Thank you.
Rakesh.S
i want to send email every day 4 pm. for that i written some code.
Please check it below code once and let me know, what i have to do.
global class scheduledEmail implements Schedulable { public static String CRON_EXP = '0 20 16 * * * *'; global static String scheduleIt() { scheduledEmail sm = new scheduledEmail(); return System.schedule('Monthly Email', CRON_EXP, sm); } global void execute(SchedulableContext SC) { sendmail(); } public void sendmail() { Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage(); string [] toaddress= New string[]{'sircilla.rakesh7@gmail.com'}; email.setSubject('Testing Apex Scheduler-Subject'); email.setPlainTextBody('Testing Apex Scheduler-Body'); email.setToAddresses(toaddress); Messaging.sendEmail(New Messaging.SingleEmailMessage[]{email}); } }
Please explain step by step.
I appriciate your response.
Thank you.
Rakesh.S
If you want send email everyday at 4 pm you need to schedule the class to run. You can schedule your class through User Interface as well as through excuteAnoumous window from develop er console.
If you want to schedule it from user interface then follow the link below.
http://salesforce.stackexchange.com/questions/3593/scheduling-an-apex-job-through-the-ui
Scheduling through developer console.
Use below code in your apex class.
Go to developer console > Excute Anoumous.
Excute the below code it runs every day 4pm.
Let me know if does not work for you.