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"
recipientType="Lead"
relatedToType="partner__c"
replyTo="{!relatedTo.ReplyTo_address__c}">
<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>
<p>Regards,</p>
</messaging:htmlEmailBody>
</messaging:emailTemplate>
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:pageBlockSection>
</apex:pageBlock>
</apex:form>
<apex:form id="previewform">
<apex:inputTextarea readonly="false" value="{!et.markup}" richText="true"/>
</apex:form>
<!-- End Default Content REMOVE THIS -->
</apex:page>
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
}
}