banner



How To Display Email Template In Visualforce Page

Visualforce Email Template

2:22 AM

Normally we create e-mail templates past navigating to Setup--> Communication Templates --> Electronic mail Templates .. Merge fields are used in these templates to display data...

To enable users to create flexible e-mail templates, Visualforce Email templates was introduced.. Yous can create templates with extensive HTML and Visualforce coding so as to develop some really appealing and effective templates.. Only there are some limitations when yous create a visualforce email template.. Before going into the limitations let us create a uncomplicated template now..


Create a Visualforce Electronic mail template by navigating to
Setup --> Communication Templates --> Email Templates --> New Template
Select "Visualforce" in the showtime step...

Requite a tilte,name,Subject area for your template. Next select the Receipent blazon and Related to (Related to denotes the object from which yous would want data to exist displayed in your Email).. Click "Save".... Remember to check "Available for utilise" to make your email template available for utilise in Workflow email alerts and whereever it may be useful....

Y'all will now meet the template detail Folio... In the "Email template" section click on "Edit Template" button... This will take y'all to a Visualforce Page editor...

You can also click on "Adhere file" button in "Standard Attachments" section to attach a file from your desktop to your email..

Beneath is a modest piece of code... You will have to put this code in the editor that appears when you click on "Edit template" button
Note: I take used "htmlEmailBody" for including HTML tags in my template.. Also, since the "Relatedto" is "Business relationship" i am displaying Account data in my template..

                    <messaging:emailTemplate subject="Testing Visualforce Electronic mail Template" recipientType="User"                                              relatedToType="Account                      "> <messaging:HtmlEmailBody > Business relationship Name : {!Relatedto.Name} <br/> Account Clarification : {!Relatedto.Description} <br/> </messaging:htmlEmailBody> </messaging:emailTemplate>                                      

What you Can...

With Visualforce email templates you can display any data from the related object in any format you lot wish.. If Relatedtotype =Account you can brandish any field of the Business relationship and you can as well display the related lists of Account .. For ex you can create a datatable with the value="{!Relatedto.Contacts}"... Similarly you lot can display other related lists...

What y'all Cannot...

You lot cannot utilise the <apex:folio> tag within your Email template.. Having said this you cannot utilize pageblock, pageblocksection or any other tag which is a child of the <apex:folio> 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 considering you would'nt know how your email would be rendered past different providers.. Always use simple and standard formatting so that your email displays uniformly across all providers...

Source: https://www.forcetree.com/2009/08/visualforce-email-template.html

Posted by: lindnerposentred.blogspot.com

0 Response to "How To Display Email Template In Visualforce Page"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel