-
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

Should You Find a Salesforce Partner Checklist 2024
Salesforce Partners offer specialized services like consulting and customization for better customer relationships and efficient business processes. But is it always necessary to find a…

Understanding Objects In Salesforce - All You Need To Know
It Takes 2 Weeks To Understand Objects in .Net and Java, But In Salesforce It Takes 2 min. Here Is How! In Salesforce, objects are…

What is the Apex Metadata API? | All You Need to Know
Let’s say that you support multiple orgs, and you’ve created a custom field. You want to add your new field to the page layouts in…
Popular Salesforce Videos
Salesforce Lightning Design System (SLDS) and Components
The Salesforce Lightning Design System (SLDS) helps you build applications with the look and feel of Lightning Experience without writing a single line of CSS.…
Salesforce Rest API | Http Methods | Salesforce Integration
This video we will discuss - What is API Different API In Salesforce Rest API in Salesforce HTTP Request HTTP methods Workbench to make HTTP…
Salesforce Einstein Prediction Builder and Einstein Next Best Action
Salaesforce Einstein Prediction Builder is a declarative tool that helps fast-track predictions based on Salesforce fields. This will help a Salesforce admin to custom-build predictions…