-
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
Unleashing Collective Intelligence: How Salesforce Communities Empower Ideas Management
Organizations are realizing the immense value of collective intelligence in driving innovation and staying ahead of the competition. Collective intelligence refers to the collective knowledge,…
Learn How to Use Custom Settings in Salesforce
What is Custom Setting? Custom Settings resemble custom items. They are by and large used to make custom arrangements of information and can be related…
Google Sheet Automation Process for Salesforce Data Pull/Push Using G-connector - Part 4
Hi All, Welcome Back --- to another blog related to the G-Connector for Salesforce. A recap for newbies In my first blog of "G-Connector for…
Popular Salesforce Videos
Salesforce Interface Sends a Command With Parameters to UiPath Assistant Using JavaScript
Salesforce interface sends a command with parameters to UiPath Assistant using Robotjs Code: https://github.com/cristinegulescu/startUiPathFromSalesforce/blob/master/SalesForceLocal.txt
Build Multi-Column Screens in Flow Builder - Spring'21 feature for the Salesforce Screen Flows
Build Multi-Column Screens in Flow Builder (Pilot) You can divide each flow screen into multiple sections and columns to create a visually appealing and effective…
Prepare for TrailheaDX: Everything Salesforce Admins Need to Know
TrailheaDX is a one-of-a-kind virtual experience that connects makers, builders, doers, and dreamers looking to improve their Salesforce skillset. This year’s event includes exciting new…