-
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

Event Management in Salesforce in 2024
How to Build a Robust Event Management System on Salesforce? Organizing events is a strategic business initiative with multifaceted benefits. From expanding professional networks to…

5 Ways To Leverage Salesforce Effectively To Fuel Your Financial Services
Salesforce is changing the face of the B2B financial services industry. Firms seem to be winning by leveraging Salesforce to increase customer engagement, personalize offers…

Integrating One Salesforce Org to Another Salesforce Org Using REST API
Hello guys, Today, I will show you how you can integrate one Salesforce org to another Salesforce Org using REST API. For this, you will…
Popular Salesforce Videos
Event Driven Development on Salesforce | All About Event in Salesforce
In this session, we will talk about Event-Driven Development in Salesforce. Let’s take a look into the many ways events have changed the way we…
Are they secure enough ? Web to Lead Forms | Validations | SPAM | CAPTCHA | Salesforce Tutorials
Are you using web to lead forms ? Do you think it's secure enough ? In this video you will get all your answers. And…
Salesforce Field Service Implementation
The possibilities for building a custom field service implementation are nearly endless when considering all the offerings in Salesforce Field Service. This 8-step guide provides…