-
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
Guide to Install an App from AppExchange
Thank you for your interest in knowing how to install apps from AppExchange for Salesforce. Use my blog as a guide, it will help you…
AI, Sustainability, and Innovation: Highlights from Dreamforce 2023
Dreamforce 2023 Key Takeaways Dreamforce 2023 was the largest and most successful Dreamforce yet, with over 180,000 attendees from all over the world. The conference…
Enhance Your Cloud Security With Salesforce Shield
Ever since Cloud came into play, Data security is the buzzword that reverberates all over the corporate world. It has been proven time and again that…
Popular Salesforce Videos
Who Should Use SFRA and PWA? | Salesforce Commerce Cloud
Different organizations need different architecture according to their needs. Organizations who want their website built on the latest technology and modern approaches can go towards…
Salesforce Integration: How to Do it the Best Way?
Once you deploy Salesforce solutions to improve the operation of your enterprise, your next logical step is to enhance the overall functionalities by integrating Salesforce…
Salesforce + WhatsApp Integration Announcement
Salesforce + WhatsApp Integration Announcement. Watch this video to learn all about the famous Salesforce + WhatsApp integration, if you have any doubts or concerns,…