You need to sign in to do that
Don't have an account?

Use Visual force template in workflow(Email Alert)
Hi,
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: {!relatedTo.name}">
<messaging:htmlEmailBody >
<html>
<body>
<p>Dear {!recipient.name},</p>
<p>Below is a list of cases related to the account: {!relatedTo.name}.</p>
<table border="0" >
<tr >
<th>Action</th><th>Case Number</th><th>Subject</th><th>Creator Email</th><th>Status</th>
</tr>
<apex:repeat var="cx" value="{!relatedTo.Cases}">
<tr>
<td><a href="https://na1.salesforce.com/{!cx.id}">View</a> |
<a href="https://na1.salesforce.com/{!cx.id}/e">Edit</a></td>
<td>{!cx.CaseNumber}</td>
<td>{!cx.Subject}</td>
<td>{!cx.Contact.email}</td>
<td>{!cx.Status}</td>
</tr>
</apex:repeat>
</table>
<p/>
<center>
<apex:outputLink value="http://www.salesforce.com">
For more detailed information login to Salesforce.com
</apex:outputLink>
</center>
</body>
</html>
</messaging:htmlEmailBody>
</messaging:emailTemplate>
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,
Sati
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: .
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?
Thanks
kdmr,
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.
thanks!
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}">
<tr>
<td>{!cx.CaseNumber}</td>
<td>{!cx.Subject}</td>
<td>{!cx.Phase__c}</td>
<td>{!cx.Type}</td>
<td>{!cx.Status}</td>
<td>{!cx.CreatedDate}</td>
<td>{!cx.Owner.Name}</td>
</tr>
</apex:outputPanel>
</apex:repeat>
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.
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!