-
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
How Salesforce Einstein Analytics Benefits Your Organization
Einstein Analytics Features Einstein Platform This platform receives the requirement of wonderful business operations and affords equipment that permits the managers and builders to craft…
Learn About Kosha Yoga Momma: A Journey to Holistic Wellness
In the world of yoga, there are many paths that lead to personal growth, healing, and wellness. One of the emerging practices that has gained…
What Are the Benefits of Salesforce Marketing Cloud?
In the era of digital transformation, effective marketing strategies are essential for businesses to engage with their audience, drive sales, and foster brand loyalty. Salesforce…
Popular Salesforce Videos
How to Set Up a B2B Marketing Analytics Plus App | Salesforce
This video shows marketers how they can create a B2B Marketing Analytics Plus app, such as Marketing Campaign Intelligence or Account-Based Marketing. So to get…
Salesforce Marketing Cloud: Journey Builder Demo
With Journey Builder from Marketing Cloud, send your customers personalized, connected experiences to build lasting relationships with your brand. Watch this video and learn.
Are Privacy laws anti-marketing? - Salesforce, GDPR and CCPA
Are Privacy laws anti-marketing? Or a great marketing opportunity for organizations? Perhaps the underlying question is: Is your Marketing outreach an unwanted nuisance? Or worse,…