function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Use Visual force template in workflow(Email Alert)



 I would like to send a mail to  a contact when case is created.The Email contains list of cases related to account.

So i created workflow with condition(case status = new) and type is Email Alert.


It is working  fine when I send it from a Send Email button on a Contact detail. When trying from work flow,its sends the mail but doesn't populate any  values.


Code as below

<messaging:emailTemplate recipientType="Contact"  relatedToType="Account"
    subject="Case report for Account: {!}">
<messaging:htmlEmailBody >
               <p>Dear {!},</p>
               <p>Below is a list of cases related to the account: {!}.</p>
         <table border="0" >
                 <tr >
                     <th>Action</th><th>Case Number</th><th>Subject</th><th>Creator Email</th><th>Status</th>

                  <apex:repeat var="cx" value="{!relatedTo.Cases}">
           <td><a href="{!}">View</a> | 
           <a href="{!}/e">Edit</a></td>
        <apex:outputLink value="">
        For more detailed information login to


Thanks for any help







When defining the Email Alert, try making the Recipient Type = Related Contact. And then make Selected Recipients = Related Contact: Contact Name.


Hope that helps,



Thanks for reply


Actually workflow sent the mail to contact but problem is , no data are showing in the email.i got mail(used above code i mentioned) and i paste here for your reference


Dear ,

Below is a list of cases related to the account: .

ActionCase NumberSubjectCreator EmailStatus
For more detailed information login to   
Can you anbody help me how to get the list (cases list for the contact) by using workflow email alert?
Thanks for any help









Can you anybody give the solution?


Thanks for any help



The VF seems to work against the Account object. If you want to run this in the context of a case, you need to make sure the relatedTo is set to the case object, relatedToType="Case" to be specific.


If you want to refer the Account associated with the case, you can get to it by using relatedTo.Account.Name etc.


Hope this helps..




I also have a VF Template that gets sent from a workflow.  It is working correcty as far as fields go.  When I test the template from the Case using Send an Email it looks great.  My client says that when he gets one sent by the workflow, it isn't formatted nicely. 


I am thinking the workflow sends the plain text version rather than the HTML version.


How do I manage that?






Did you ever get this working? I want to send a contact a list of their open cases, say every Friday morning. Not sure if this is possible.




I was able to use a where clause to get "open" cases (see below). Now I'm just wondering if it's possible to send emails on a scheduled basis (e.g. Every Friday at 9am)


<apex:repeat var="cx" value="{!relatedTo.Cases}">
       <apex:outputPanel rendered="{!cx.IsClosed= FALSE}">


If you got it working,please send the steps to follow.Because i am in the same position.When i tested in the preview mail works fine,but triggered from workflow empty data list,basically id not passing .


Thanks in advance.

Keith Weaver 8Keith Weaver 8
I also am having the same issue.  You have a visualforce email 
<messaging:emailTemplate subject="Redfin Partner Program - We're almost ready to go live!" recipientType="Contact" relatedToType="SFDC_Candidate__c">
<messaging:htmlEmailBody >
<p><span style="font-family: helvetica;">Hi {!recipient.Name},</span></p>
<p><span style="font-family: helvetica;">Thank you for taking time to interview to be part of the Redfin partner program. We are excited to move forward with your application.</span></p

Looks great when I look at the email preview but does not include the merge fields when I send it using an email alert.  Please help!