Make a Responsive Visualforce Email Template
Community Hub emails are built with a layout which fits well on any screen size. Most email systems (Gmail included) remove <head>
and <style>
tags from emails. As such, all CSS styles need to be inline, and to do this, an inliner tool is used.
- Create a custom email:
- Clone the ams-community repo locally. The packaged version of Community Hub includes the inline-ified emails and would be cumbersome to customize. The un-inlined version of the emails live in this repository in the src/emails_non_inlined folder.
- Find the email you're looking to customize i.e. "create_new_account.html" and open it in the source code editor of your choice.
- Make any modifications to this file including CSS rules, content, etc.
The main body of the email can be found near the bottom, and looks like this.
XML<h1>Nice to meet you, {!Receiving_User.FirstName}.</h1> <p>You're now part of {!Community_Name}, which is a great start.</p> <p>Click below to see what's next at {!Community_Name}.</p> <table class="button"> <tr> <td> <a href="{!Community_Url}">Get Started Now</a> </td> </tr> </table>
- See the article titled Merge Fields for Communities for more details on the fields available to Communities email templates.
- Open the file in Chrome for easy previewing.
- Copy the contents of the text inside the file.
- Go to the MailChimp inliner tool, or the Zurb inliner tool, either will work.
- Copy the output of the inliner to your clipboard.
- Create a email template with the inlined content:
- From Setup, click Communication Templates | Email Templates.
- Click New Template.
- Choose the Custom (without using Letterhead) email type.
- Store the template in the folder of your choice, give it a logical name, make sure Available For Use is checked, and set the encoding to UTF-8.
- Click Next.
- Give the email a subject and paste in the output from the inliner tool.
- Click Next.
- Specify plaintext content.
- Click Save.