-
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
Top 7 Salesforce Extensions: Blessing In Disguise For Small Businesses
Salesforce, a popular customer relationship management platform, has progressed into being one of the most personalized sales management platforms in the CRM market. Countless Salesforce…
Top 20 Factors To Consider When Choosing CRM For Small Business | Salesforce
Small or mid-sized businesses are renovating our nation’s economic structure. They have delivered a huge contribution towards its enhancement by generating a magnitude of job…
Key Salesforce Benefits for Healthcare
During the peak of COVID-19, the importance of a streamlined workflow that would make the most efficient use of healthcare resources such as medicines, equipment,…
Popular Salesforce Videos
Salesforce On-Demand Administrator
Apphienz's On-demand Administrator delivers much more than the company's expectations. It is hands-on, makes the work easy, efficient and productive along with being available to…
Introduction to Salesforce Nonprofit Cloud for Program Management
Each nonprofit’s mission and the program is unique, but with Salesforce’s highly configurable and customizable platform, you can manage your entire program from one central…
Salesforce Development Course for Intermediate Developers
If you want to become a Salesforce developer in 2021 then watch this video, here you'll learn about some of the best Salesforce Development Course…