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 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}
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…
You cannot use the