-
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
8 Best Salesforce Features For Sales Managers 2022
Salesforce Sales Cloud has the greatest customer base of any Sales CRM in the world. Salesforce has solidified CRM for high-performance sales companies by focusing…
The Ultimate Guide to Agentforce: Everything You Need to Know
Imagine having a personal assistant who’s always available and can seamlessly handle various tasks; that’s what Agentforce is. It is like hiring a team of…
Popular Salesforce Videos
Salesforce Trailhead Bootcamp - Fast Track your Salesforce Certification - $700 OFF LIMITED TIME
If want to fast track the path to your Salesforce Administrator Certification then this video is for you! This offer includes your $200 Certification Voucher…
Dreamforce 2021 Main Keynote - Welcome to the Trusted Enterprise | Salesforce
Today, every business has to transform to become a Trusted Enterprise. Join Marc Benioff & special guests to learn how Customer 360 helps businesses of…
Unleash the Power of Compare Tables | Salesforce Video
In this video, you will learn how to use compare tables to calculate complex calculations quickly, which you can then use to visualize your data.…