VISUALFORCE EMAIL TEMPLATE | Techila
1074
single,single-post,postid-1074,single-format-standard,ajax_updown_fade,page_not_loaded,,qode_grid_1300,footer_responsive_adv,hide_top_bar_on_mobile_header,qode-content-sidebar-responsive,qode-theme-ver-9.4.2,bridge,wpb-js-composer js-comp-ver-4.12,vc_responsive
 

VISUALFORCE EMAIL TEMPLATE

VISUALFORCE EMAIL TEMPLATE

VISUALFORCE EMAIL TEMPLATE

VisualForce email templates came as a part of winter  ‘09 release which leverages on VisualForce technology to provide underlying framework for email templates.

You need to know three tags to create VisualForce email template

1) <messaging:emailTemplate> – in which you specify recipient type, relatedToType, subject and email address that they can reply back to.

2) <messaging:htmlEmailBody> – in which you define the html content you want to show in your Email.

3) <messaging:plainTextEmailBody> – in which you include the text version of your Email.

Let me show you a simple example of how to create a VisualForce email template. We are going to create an email template which sends email about contacts that are related to an account.

The first step is to create an email template by going to Setup -> Administration Setup -> Communication Templates -> Email Templates -> New Template

 

VISUALFORCE EMAIL TEMPLATE


<messaging:emailTemplate subject="Contact Information for Account: {!relatedTo.name}" recipientType="Contact" relatedToType="Account" replyTo="abc@gmail.com">
<messaging:htmlEmailBody >
<html>
<body>
<p> Dear {!recipient.name},</p>
<p> Below is the list of contacts related to your account: {!relatedTo.name}.</p>
<table border="0">
<tr>
<th> Action </th>
<th> Contact Name </th>
<th> Contact Email </th>
</tr>
<apex:repeat var="con" value="{!relatedTo.Contacts}">
<tr>
<td><a href="na7.salesforce.com/{con.id}"> View </a>
<a href="na7.salesforce.com/{con.id}/e"> Edit </a></td>
<td> {!con.Name} </td>
<td> {!con.Email} </td>
</tr>
</apex:repeat>
</table>
</body>
</html>
</messaging:htmlEmailBody>
<messaging:plainTextEmailBody >
Dear {!recipient.name},

Below is the list of Contacts related to Account: {!relatedTo.name}.

[Contact Name] – [Contact Email]
<apex:repeat var=”cont” value=”{!relatedTo.Contacts”>
[cont.Name]  –  [cont.Email]
</apex:repeat>

For more detailed information login to http://www.salesforce.com
</messaging:plainTextEmailBody>
</messaging:emailTemplate>

 

Last step is to test and verify merge fields. Click Send Test and Verify Merge Fields button to verify merge fields.

VISUALFORCE EMAIL TEMPLATE

 

Courtesyhttps://sivatejaforce.wordpress.com/2011/02/09/visualforce-email-template/

“Know more about Salesforce Consulting at Techila”

Author: techila

No Comments

Post A Comment