So, let's say you want really beautiful emails sent from Salesforce. You build all the HTML to make them look amazing and add a bit of Visualforce to make them more dynamic. But then you add a couple of more templates that all share the underlying design and the only thing that is different between them is the dynamic text in between the header and the footer. This means the design is now hardcoded into every single email template and if the design template changes you have to change them all.

So my first instinct is to use apex:composition in the email templates but I'm pretty sure that I read somewhere once that this is not supported. If this is the case - what is the alternative? And are they any plans to fix this? Is there a way to do this in Lightning email templates?

1 Answer 1


You can use custom Visualforce Components and then use it inside your Visualforce Email Template. I used similar thing in one of the projects, and it works.

Salesforce References:

  1. VF Email Template
  2. Custom Controllers and Components with VF Email Templates
  • I'm not quite sure how this is supposed to help. Sure - I can put e.g. text in a component but how do I put the design template (aka header & footer) into a component? Isn't that what apex:composition is for?
    – Semmel
    Commented Oct 24, 2020 at 21:10
  • What do you mean by design template? Do you mean header and footer in HTML with formatting using CSS? Visualforce already supports directly writing HTML, CSS & JavaScript inside VF page or VF component. Commented Jul 10, 2021 at 11:46

You must log in to answer this question.

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