+ Start a Discussion
John Neilan 2John Neilan 2 

Visualforce Email Template Not Showing Recipient Name

I have a Visualforce email template that is being used as part of a WFR Email Alert. I have multiple recipients in the email alert. How would I get my VF template to email each of these recipients?

VF Template:
 
<messaging:emailTemplate recipientType="Contact"
  relatedToType="Account"
  subject="Notification - {!relatedTo.Name} - {!TODAY()}"
  replyTo="test@test.com">
  <messaging:htmlEmailBody >
    <html>
      <body>
        <STYLE type="text/css">
          TH {font-size: 11px; font-face: arial;background: #CCCCCC;
               border-width: 1;  text-align: center } 
          TD  {font-size: 11px; font-face: verdana } 
          TABLE {border: solid #CCCCCC; border-width: 1}
          TR {border: solid #CCCCCC; border-width: 1}
        </STYLE>
        <font face="arial" size="2">
          <p>Hi {!recipient.Name},</p>
          <p>We would like to inform you of the following issue(s) found on {!relatedTo.Name}.&nbsp;We would appreciate your immediate attention to this matter.<br/></p>
          <table border="0" columns="2">
            <apex:variable value="{!1}" var="ViolationNum"/>
            <apex:repeat var="cx" value="{!relatedTo.Cases}">
            <apex:outputPanel rendered="{!IF(cx.Status = 'Escalated Internal - Past Due' && cx.Escalate_to_Client__c = TRUE,TRUE,FALSE)}">
                <tr>
                    <td colspan="2"><b><u>Violation #<apex:outputText value="{!FLOOR(ViolationNum)}"/></u></b></td>
                    <apex:variable var="ViolationNum" value="{!ViolationNum + 1}"/>
                </tr>
                <tr>
                    <td width="25%">Case Number</td>
                    <td width="75%">&nbsp;&nbsp;&nbsp;{!cx.CaseNumber}</td>
                </tr>
                <tr>
                    <td width="25%">Site Name(s)</td>
                    <td width="75%">&nbsp;&nbsp;&nbsp;{!cx.Sample_URLs__c}</td>
                </tr>
                <tr>
                    <td width="25%">Violation Type</td>
                    <td width="75%">&nbsp;&nbsp;&nbsp;{!cx.Type_of_Violation__c}</td>
                </tr>
                <tr>
                    <td width="25%">Description of Violation</td>
                    <td width="75%">&nbsp;&nbsp;&nbsp;{!cx.Compliance_Violation_Description__c}</td>
                </tr>
                <br/><br/>
            </apex:outputPanel>
            </apex:repeat>
            </Table>

            Please respond to this email by 
                <b><apex:outputText value="{0, date, MMMM d','  yyyy}">
                    <apex:param value="{!CASE( MOD( TODAY() - DATE(1900, 1, 7), 7),0, TODAY() + 2,1, TODAY() + 2,2, TODAY() + 2,3, TODAY() + 2,4, TODAY() + 4,5, TODAY() + 4,6, TODAY() + 3,null)}"/>
                </apex:outputText></b>.<p/>

            Thank you for your prompt attention to this matter!<br/><p/>
        </font>
      </body>
    </html>
  </messaging:htmlEmailBody> 
</messaging:emailTemplate>

 
Arpit Jain7Arpit Jain7

Hey John,

You can try below steps:
- create a Workflow Rule for when the mail should be sent
- link an 'Email Alert' to the workflow, which contains both a reference to your VisualForce e-mail template and a list of recipients for the e-mail. The recipients can be either drawn from the record or hardcoded in the Email Alert.

Hope that helps.