-
Salesforce Error : Callout from scheduled Apex not supported.
Hi ,
I am using apex code to send a report as an attachment and schedule it but in Scheduling i am getting this error
"Scheduler: failed to execute scheduled job: jobId: 7012D00000IDppK, class: common.apex.async.AsyncApexJobObject, reason: Callout from scheduled Apex not supported."
here is my code:
global class Exporter implements System.Schedulable {
global void execute(SchedulableContext sc) {
ApexPages.PageReference report = new ApexPages.PageReference('/00O41000001kkjC?csv=1');
Messaging.EmailFileAttachment attachment = new Messaging.EmailFileAttachment();
attachment.setFileName('scheduledreport.csv');
attachment.setBody(report.getContent());
attachment.setContentType('text/csv');
Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
message.setFileAttachments(new Messaging.EmailFileAttachment[] { attachment } );
message.setSubject(' Test Client list Report');
message.setPlainTextBody('The report is attached.PFA');
message.setToAddresses( new String[] { 'cromahead@gmail.com' } );
Messaging.sendEmail( new Messaging.SingleEmailMessage[] { message } );}
}
Now i am not getting that where i am using Callout services. How to resolve this?Thanks in advance!
Rahul Kumar
Log In to reply.
Popular Salesforce Blogs
Salesforce Lightning Web Components: The new way of creating robust components for modern browsers
Salesforce has been on a great journey with the Lightning modules. In 2014, Salesforce had launched the Lightning component framework that was supported by the…
Salesforce Admin vs. Consultant: Which One Should I Choose?
If chosen correctly, you can create a successful career in Salesforce. However, you have to understand the specific roles and responsibilities that every post has…
Best Practices for Importing Data into Salesforce
The most efficient methods for arranging the data before moving it once you’ve decided which method is the best for importing or exporting your data. …
Popular Salesforce Videos
How to Find Job as a Fresher in Salesforce - Tips and Tricks
In this video Rohit Puri gives a detailed explanation of the questions that everyone has regarding Salesforce jobs, how to find jobs in Salesforce on…
How to Get a Job in Salesforce as a Fresher | Video Guide
Looking to start a career in Salesforce. Wondering how to get a job in Salesforce as a fresher. Check out this video it will guide…
Salesforce Development Master Training | Salesforce Development Course
Shrey Finally launched the most awaited Salesforce Development Master Training. Features of the course are: Learn Salesforce Development from Scratch with more than 100 on-demand…