I'm trying to include email template preview inside custom VF page, I've visualforce email template with messaging:htmlEmailBody only without plain text version.

I created custom VF to get email preview from controller and display it in this page. but body column is empty, I got markup of the email but when I try to display it display tags. not like preview from email template page inside force.com . I put it inside apex:inputTextarea with richText and readonly. I have button to insert lead and reRender template preview. but I got this error when I click on that button.

Rerender is not currently supported with rich text editing enabled 

So what I need is to display the email template preview with markup (Styled).

Email Template

<messaging:emailTemplate subject="Welcome Partner" 
    <messaging:htmlEmailBody >
        <p>Dear {!recipient.firstname},</p>

        <h2 style="color:#009DDC;">Welcome {!relatedTo.Company__c}</h2>

        <p><strong><i>This is sample:</i></strong> You received email!</p>


VF page

<apex:page showHeader="false" controller="emailctrl" >
  <!-- Begin Default Content REMOVE THIS -->
  <apex:form id="theform" >
  <apex:pageBlock >
      <apex:pageBlockSection >
          <apex:inputField required="true" label="First Name" value="{!l.firstname}"/>
          <apex:inputField label="Last Name" value="{!l.lastname}"/>
          <apex:inputField label="Email" value="{!l.email}"/>
          <apex:inputField label="Company" value="{!l.company}"/>
          <apex:commandButton value="Preview" action="{!preview}" reRender="previewform"/>


  <apex:form id="previewform">
      <apex:inputTextarea readonly="false" value="{!et.markup}" richText="true"/>
  <!-- End Default Content REMOVE THIS -->

Apex Class

public with sharing class emailctrl {
    public lead l{set;get;}
    public EmailTemplate et;

    public EmailTemplate getEt(){

        et = [SELECT id,body,Markup,HtmlValue
              FROM EmailTemplate 
              WHERE DeveloperName = 'welcome_partner'];
        return et;

    public void preview(){
        // do nothing
  • I want to display it inside VF custom page. Commented Feb 16, 2016 at 9:49

1 Answer 1

<apex:inputTextarea readonly="false" value="{!et.markup}" richText="true"/>

Instead use this.

 <apex:outputText value="{!et.markup}" escape="false"/>
  • Your welcome.....
    – Ratan Paul
    Commented Feb 16, 2016 at 10:21
  • You deserve that Mr. Ratan, you helped me more than once. thanks Commented Feb 16, 2016 at 10:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .