Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to be able to load and render an email template in a visualforce page. What are my options here?

I understand that loading it is as simple as querying the EmailTemplate table. Now how do I render it in my visualforce page so the letterhead appears, etc?

share|improve this question
Summer 16 resolves this here: – cropredy May 1 at 23:21

Your somewhat limited in your ability to render the template with any of the built-in Visualforce components, for one there isn't a way to get 'Merge Fields' to render the accompanied values.

With that in mind, I think the safest way to do it would be to create a frame and render the EmailTemplate.HtmlValue (EmailTemplate) as un-escaped HTML once you have queried the template in your VF Controller (probably would query the template by name)

share|improve this answer
Hey thanks! Is there anything special I need to do about the <![CDATA[]]> markups contained in EmailTemplate.HTMLValue? – jmrjulian Dec 26 '12 at 21:27

you can get Merge Fields from email Template..

for(EmailTemplate templ : selectedTemplateList) 

Organization org = [SELECT id, Name FROM Organization]; Id orgId = org.Id; String Name = org.Name;

      templ.Body = templ.Body.replace('{!Organization.Name}',org.Name); 

            this.emailTemp.body = templ.Body.replace('\n','<br>') ;
            this.emailTemp.htmlValue =  templ.Body.replace('\n','<br>') ;
            this.emailBody = templ.Body; 
            this.emailSubject = templ.Subject; 


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.