VisualForceEmailTemplates sample ideas

How do I leverage Idea's merge field in an email template?

With Visualforce email templates you can access and leverage idea's merge fields. Use the relatedToType to set the related to object to an idea, and then reference the field names you want to include. As you can see from the sample below, it is fairly easy to get started and include idea data in your email template.

First I will set the top level tag and define the recipientType, RelatedToType, Subject and a reply-to address for every time the template is used.

<messaging:emailTemplate subject="Your Idea '{!relatedTo.title}' has been created"
recipientType="Contact" 
relatedToType="Idea" 
replyto="test@acme.com">

Secondly I am defining the html body portion of my email template and referencing the Idea fields, by using the {!relatedTo.fieldName} annotation.

<messaging:htmlEmailBody >
<font face="verdana" size="2">
Congratulations, your idea {!relatedTo.title} has been created. <p>

You can view your idea <a href="https://na1.salesforce.com/ideas/viewIdea.apexp?id={!relatedTo.id}">here</a> 
and vote for this and other great ideas in the Dreamforce IdeaExchange
</p></font>
</messaging:htmlEmailBody>

Finally I also create a text version of the template and any use not able to read the html version of the content.

<messaging:plainTextEmailBody >

Congratulations, your idea {!relatedTo.title} has been created.

You can view your idea here
https://na1.salesforce.com/ideas/viewIdea.apexp?id={!relatedTo.id}  

Vote for this and other great ideas in the Dreamforce IdeaExchange
</messaging:plainTextEmailBody>
</messaging:emailTemplate>

Here is an actual template:

<messaging:emailTemplate subject="Communityforce New Idea '{!relatedTo.title} '" 
recipientType="User" 
relatedToType="Idea"
replyTo="YourEmailAddress">

<messaging:htmlEmailBody >
    <font face="verdana" size="2">
<p> This is an auto-notification. A new idea has been posted, {!relatedTo.title}. Catagorie(s): {!relatedTo.Categories}</p>
Full description:<p/>
{!relatedTo.Body}
<p/>
You can view the new idea <a href="https://xxx.salesforce.com/ideas/viewIdea.apexp?id={!relatedTo.id}">here</a> and vote for it.

</font>
</messaging:htmlEmailBody>

<!-- HTML above and plain text beleow -->

<messaging:plainTextEmailBody >
This is an auto-notification.
A new idea has been posted, {!relatedTo.title}. Full description:
{!relatedTo.Body}
You can view/vote for the idea at https://xxx.salesforce.com/ideas/viewIdea.apexp?id={!relatedTo.id}
    
</messaging:plainTextEmailBody>

</messaging:emailTemplate>