• Bruno Rosan
  • NEWBIE
  • 5 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 1
    Replies
I am trying to send an email with Apex using a visualforce page as the html body of the email by using PageReference.getContent(); However, when I call getContent() it is rendering the page without the one repeat component. I know that the collection the repeat is iterating over has data because if I redirect to the same PageReference the repeat component gets rendered as expected. The apex code looks like this:
 

PageReference emailTemplate = Page.ProjectInvoiceTrackingEmailTemplate;Blob emailBody = emailTemplate.getContent();System.debug(emailBody.toString());

 the template looks like this:

 

<apex:page id="templatePage" sidebar="false" showHeader="false" controller="ProjectInvoiceEmailController"> <h1>Template header</h1> <apex:repeat value="{!actualProjectsToNotify}" var="project" rendered="true"> <apex:outputText value="{!project.projectName}" /> </apex:repeat> <h3>page end</h3></apex:page>

Does anyone have any ideas why this wouldn't be rendered when calling getContent(), but it is rendered when that same page reference is rendered in the browser? 

 

 

 
  • May 20, 2009
  • Like
  • 1
I am trying to send an email with Apex using a visualforce page as the html body of the email by using PageReference.getContent(); However, when I call getContent() it is rendering the page without the one repeat component. I know that the collection the repeat is iterating over has data because if I redirect to the same PageReference the repeat component gets rendered as expected. The apex code looks like this:
 

PageReference emailTemplate = Page.ProjectInvoiceTrackingEmailTemplate;Blob emailBody = emailTemplate.getContent();System.debug(emailBody.toString());

 the template looks like this:

 

<apex:page id="templatePage" sidebar="false" showHeader="false" controller="ProjectInvoiceEmailController"> <h1>Template header</h1> <apex:repeat value="{!actualProjectsToNotify}" var="project" rendered="true"> <apex:outputText value="{!project.projectName}" /> </apex:repeat> <h3>page end</h3></apex:page>

Does anyone have any ideas why this wouldn't be rendered when calling getContent(), but it is rendered when that same page reference is rendered in the browser? 

 

 

 
  • May 20, 2009
  • Like
  • 1