Skip to main content
Hello,

Is it possible to include a visualforce (or HTML) page in a visualforce email template?

The use case is I have a set of data that changes, but needs to be appended to several different kinds of emails.  I would like to keep this data in a single visualforce page which I can update only once, and automatically include it at the end of the various other email templates I create.  

(I new here).  Thanks for the help.
4 answers
  1. May 18, 2017, 9:02 PM
    Yes, You can. 

    First, Create a Visualforce Component Instead of Visualforce Page. 

    Example: Component Name - awesomeComp

    <apex:component>

    <apex:attribute name="record" description="The type of record we are viewing."

    type="Object" required="true"/>

    <apex:pageBlock title="Viewing {!record}">

    <apex:detail />

    </apex:pageBlock>

    </apex:component>

    You can learn more about components Here. 

    https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_comp_cust_def.htm

    Then you can create Your visualforce email template and add it to the template.

    <messaging:emailTemplate

    subject="Hey there!">

    <messaging:HtmlEmailBody >

    <html>

    <head>

    <meta content="text/css;charset=utf-8" http-equiv="Content-Type"/>

    <meta name="Template" content="Response"/>

    </head>

    <body>

    <p><b>Your data</b>

    <c:awesomeComp record="" /> // your Component.

    </p>

    </body>

    </html>

    </messaging:HtmlEmailBody>

    </messaging:emailTemplate>

    Best,

    Nithesh
0/9000