I want to display the visualforce email template inside a panel with live preview if possible, so while I'm writing lead_name__c for example It will be bind to template where Dear recipient.lead_name__c ?? or just display it only without live preview.

What I need is, to display email preview inside custom VF page.

  • your question is unclear. What do you mean by live preview? When you create visualforce email template you already see it
    – Patlatus
    Feb 11, 2016 at 9:13
  • Yes, but I've custom visualforce page to create lead, I want to preview the email which will be sent in this VF custom page so the user who create the lead can see the email will be sent @Patlatus, you got it?? Feb 11, 2016 at 9:17

1 Answer 1


I believe this article on Salesforce Documentation should help you understand about VisualForce Email Template creation and live preview

Basically you just need to go to

  1. Administer \ Communication Templates \ Email Templates,
  2. then Click New Template button.
  3. Choose Visualforce and click Next button.
  4. Setup parameters like folder to store it, name, unique name, email subject, Recipient type, Related to type and click Save button.
  5. => voilà: you already see you live preview saying:

    Congratulations! This is your new Visualforce Email Template.


To show email template preview in another page, you may need to have controller property like this:

public String templateBodyPreview { get {
EmailTemplate  et = [ select id, name, body, subject, HTMLValue  from EmailTemplate where name = 'test' ]
return 'Subject: ' + et.subject + '<br/>\r\nBody preview:' + et.body;
 } private set; }

and in your visualforce page you can reference this property like

  • this is email preview in email template page, I need to display that preview inside custom VF Page, not inside salesforce.com Feb 11, 2016 at 9:39
  • if you don't care about merge fields, you may just query for email template like i have posted in my updated answer, note that "Available For Use" checkbox should be checked, otherwise you will receive null as subject or body
    – Patlatus
    Feb 11, 2016 at 10:20

You must log in to answer this question.

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