Home Custom Email Template Visualforce Email Template 3
Create a Visualforce Email template by navigating to
Setup –> Communication Templates –> Email Templates –> New TemplateSelect “Visualforce” in the first step…

Give a tilte,name,Subject for your template. Next select the Receipent type and Related to (Related to denotes the object from which you would want data to be displayed in your Email).. Click “Save”…. Remember to check “Available for use” to make your email template available for use in Workflow email alerts and whereever it may be useful….

You will now see the template detail Page… In the “Email template” section click on “Edit Template” button… This will take you to a Visualforce Page editor…

You can also click on “Attach file” button in “Standard Attachments” section to attach a file from your desktop to your email..

Below is a small piece of code… You will have to put this code in the editor that appears when you click on “Edit template” button
Note: I have used “htmlEmailBody” for including HTML tags in my template.. Also, since the “Relatedto” is “Account” i am displaying Account information in my template..

  relatedToType="Account">    Account Name : {!Relatedto.Name} 
Account Description : {!Relatedto.Description}

What you Can…

With Visualforce email templates you can display any data from the related object in any format you wish.. If Relatedtotype =Account you can display any field of the Account and you can also display the related lists of Account .. For ex you can create a datatable with the value=”{!Relatedto.Contacts}”… Similarly you can display other related lists…

What you Cannot…

You cannot use the tag inside your Email template.. Having said this you cannot use pageblock, pageblocksection or any other tag which is a child of the tag.. You can use outputfield,outputtext,datatable etc.. Do not attempt too much of styling and formatting for your email templates unless it is extremely necessary because you would’nt know how your email would be rendered by different providers.. Always use simple and standard formatting so that your email displays uniformly across all providers…

You may also like

Leave a Comment