We use Apex Scheduler to schedule a controller to execute it at a given time in future. For this make an Apex Scheduler Controller and to schedule this controller go to...
Administration Setup->Monitoring->Scheduled Jobs from there we select that Controller class and then provide some time and date to execute it in future.
Below is a sample code of the Apex Scheduler Controller to send an email : global class ApexScheduledClass Implements Schedulable { global void execute(SchedulableContext sc) { sendmail(); } public void sendmail() { Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage(); string [] toaddress= New string[]{'vkumar.sri@gmail.com'}; email.setSubject('Testing Apex Scheduler-Subject'); email.setPlainTextBody('Testing Apex Scheduler-Body'); email.setToAddresses(toaddress); Messaging.sendEmail(New Messaging.SingleEmailMessage[]{email}); } }
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
We use Apex Scheduler to schedule a controller to execute it at a given time in future. For this make an Apex Scheduler Controller and to schedule this controller go to...
Administration Setup->Monitoring->Scheduled Jobs from there we select that Controller class and then provide some time and date to execute it in future.
Below is a sample code of the Apex Scheduler Controller to send an email : global class ApexScheduledClass Implements Schedulable { global void execute(SchedulableContext sc) { sendmail(); } public void sendmail() { Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage(); string [] toaddress= New string[]{'vkumar.sri@gmail.com'}; email.setSubject('Testing Apex Scheduler-Subject'); email.setPlainTextBody('Testing Apex Scheduler-Body'); email.setToAddresses(toaddress); Messaging.sendEmail(New Messaging.SingleEmailMessage[]{email}); } }
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
Hi
We use Apex Scheduler to schedule a controller to execute it at a given time in future. For this make an Apex Scheduler Controller and to schedule this controller go to...
Administration Setup->Monitoring->Scheduled Jobs from there we select that Controller class and then provide some time and date to execute it in future.
Below is a sample code of the Apex Scheduler Controller to send an email :
global class ApexScheduledClass Implements Schedulable
{
global void execute(SchedulableContext sc)
{
sendmail();
}
public void sendmail()
{
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
string [] toaddress= New string[]{'vkumar.sri@gmail.com'};
email.setSubject('Testing Apex Scheduler-Subject');
email.setPlainTextBody('Testing Apex Scheduler-Body');
email.setToAddresses(toaddress);
Messaging.sendEmail(New Messaging.SingleEmailMessage[]{email});
}
}
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
All Answers
Hi
We use Apex Scheduler to schedule a controller to execute it at a given time in future. For this make an Apex Scheduler Controller and to schedule this controller go to...
Administration Setup->Monitoring->Scheduled Jobs from there we select that Controller class and then provide some time and date to execute it in future.
Below is a sample code of the Apex Scheduler Controller to send an email :
global class ApexScheduledClass Implements Schedulable
{
global void execute(SchedulableContext sc)
{
sendmail();
}
public void sendmail()
{
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
string [] toaddress= New string[]{'vkumar.sri@gmail.com'};
email.setSubject('Testing Apex Scheduler-Subject');
email.setPlainTextBody('Testing Apex Scheduler-Body');
email.setToAddresses(toaddress);
Messaging.sendEmail(New Messaging.SingleEmailMessage[]{email});
}
}
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
How can we call this sendmail() which is present in the mail controller.