Skip to content

Visualforce component for VF email templates #111

@jkincaid-dbservices

Description

@jkincaid-dbservices

Problem: Visualforce email templates did not have a clean way to add the unsubscribe link without creating additional formula fields that would parse the URL and title into separate fields for injecting into the template via merge fields.

Solution: There is now an UnsubscribeLink Visualforce component that can be added to the Visualforce email template in the HTML email body. Example:

<messaging:emailTemplate subject="This is a test" recipientType="Contact" >
  <messaging:htmlEmailBody >
     Congratulations!
     This is your new Visualforce Email Template.
     <c:UnsubscribeLink recipientId="{!recipient.Id}"></c:UnsubscribeLink>
   </messaging:htmlEmailBody>
</messaging:emailTemplate>

This template would output

Congratulations! This is your new Visualforce Email Template. Click here to unsubscribe.

The component only needs one parameter: the recipient's ID, which will be either the contact ID or the lead ID of the contact/lead you are sending the email to.

Unaddressed Issues This solution does not address text emails nor Visualforce text email templates. Text emails cannot hide a link with a title and would need to use the raw URL.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions