-
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[] { '[email protected]' } );
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
Wonder How Salesforce Commerce Cloud Provides Seamless User Experiences for eCommerce Businesses
Shifting primary demand from offline shopping to online shopping, eCommerce innovations have revolutionized the industry. As customers indulge in online shopping, they seek to demand…
How to pass Date field from Salesforce Lightning Component to Apex Controller?
We can't directly pass the Date field value from Lightning Component to its Apex Controller. What we need is to: Capture the value of Date…
Salesforce declares a new Content Management System
Salesforce announced a new tool named Salesforce Content Management System recently which is designed in an optimized manner to deliver a quality customer experience across multiple channels. The…
Popular Salesforce Videos
Salesforce Guide to Sharing Architecture
The Salesforce sharing model is an essential element in your organization's ability to provide secure application data access. Therefore, it's crucial to architect your sharing…
Salesforce Winter'21 New Apex Features
So wait is over... In this tutorial we would discuss many new Apex Features as below : Use Safe Navigation Operator PATCH HTTP Method in…
Salesforce Visualforce and Force.com Development Tutorial || Beginner
Learn to set up a web page using force.com and create forms for users to input information into Salesforce. For more Salesforce tips and tricks…