Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7538545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:08:53+00:00 2026-05-30T07:08:53+00:00

I have an APEX class that is used to send an email out each

  • 0

I have an APEX class that is used to send an email out each day at 7PM:

global class ReportBroadcaster implements Schedulable {

    global ReportBroadcaster() {
    }

    global void execute(SchedulableContext sc) {
      send();
    }

    global void send() {
      PageReference page = new PageReference('/apex/nameofvfpage');
      page.setRedirect(true);
      Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
      email.setSubject('Example Subject');
      email.setHtmlBody(page.getContent().toString());
      email.setToAddresses(new String[]{'test@test.com'});
      Messaging.sendEmail(new Messaging.SingleEmailMessage[]{email});     
    }
}

When I execute the send() method via an instance of the ReportBroadcaster via anonymous APEX, it is delivered as expected. However, when I schedule the class, the email is delivered with a blank body. If I switch the email body to plain text, it delivers fine (but that doesn’t work for me).

How do I make this work?

UPDATE:

You cannot call getContent() on PageReference instances from either scheduled APEX or @future methods (I’m not sure why that would be, but it is what it is). I think that the solution will be to create a web service that I’ll call from the @future method. Seems incredibly hacky, but I’m not sure what else I could do.

FINAL UPDATE:
This is how to send HTML emails from scheduled APEX:

  • Create a class that implements the Schedulable interface.
  • Have the execute() method call an @future method.
  • Have the @future method call a web service enabled method in the class that sends the email.

While this approach is roundabout, it works.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T07:08:54+00:00Added an answer on May 30, 2026 at 7:08 am

    getContent() method is not supported in scheduled Apex. See the last line of this page:

    http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_scheduler.htm

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written an apex class that will create a PDF quote and attach
In Apex there is a provision to send email through Apex class. So similarly
I have written a working class in Apex. It is an Email service extender,
I have written an Apex class in a Salesforce managed package which uses the
I'm using Oracle APEX and I have a report region in a page that
I have a html/javascript web page that I need to run unmodified on APEX
Friends, My apex page has several different radio groups, each one can have the
I have two tables in APEX that are linked by their primary key. One
I have created a custom object Assure__c and a custom apex class insEnfant like
I have an image that is in my apex application with the id tag

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.