-
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's Latest Mascot is here: Flo, The Flying Squirrel
Recently, Salesforce introduced a new mascot, a friend of Astro and family, Flo. With the help of automation, this flying squirrel will assist you in…
No Code Salesforce and WhatsApp Integration
Businesses are increasingly using messaging as their primary channel for customer communication. Each week, more than a billion users connect with a business account using…
Popular Salesforce Videos
Salesforce Einstein Keynote: AI for CRM
Salesforce Einstein is delivering more than one billion predictions every day, helping companies get a new level of insight about their business and their customers.…
Salesforce Interview | Marketing Cloud Success
What's it like to learn Marketing Cloud from scratch? Akasia Perran has the answers and in this video, I ask her about her experience starting…
Lightning Component Development - Applying Stylesheet, Create Basic Lightning Component
Welcome to Lightning Component Development Sessions. This is the initiative to help Salesforce Community in learning Lightning which we believe is future of Salesforce. Check…