DEV Community

Cover image for 8 Tips for Pixel-Perfect Email Templates in Salesforce
Oleksandra Todorenko
Oleksandra Todorenko

Posted on

8 Tips for Pixel-Perfect Email Templates in Salesforce

Creating Lightning Email Templates in Salesforce is essential for Sales Managers and Marketing professionals to streamline communication and maintain consistent branding. Ensuring that recipients receive emails with the expected style and appearance is crucial for a seamless and professional experience. Let's explore the best practices to achieve this goal and deliver effective email communication to our audience.

Validate in different Mail clients

Once you've prepared a template in Salesforce and tested it in Gmail, take a moment before saving it as the final version. Some mail clients may not support all CSS properties, leading to unexpected appearances for recipients. Notably, the Outlook app for Windows lacks support for numerous HTML elements and CSS properties, such as max-width, border-radius, styles on p, div elements, etc.
Also, there are platforms where you can validate the appearance of your email in different versions, platforms and devices, just by inserting its HTML template. Unfortunately, I found only paid solutions (Litmus, Email on Acid). Please share in the comments if you can recommend other platforms, especially free ones :)

Use Email Template Builder

Salesforce's Email Template Builder allows easy creation of email templates with a drag-and-drop functionality. To enable this feature, users need Access Drag-and-Drop Content Builder permission. Once granted, they can click the 'Edit in Builder' button to get started.

Edit in builder button

Despite some limitations, the Email Template Builder allows the insertion of HTML code, images, text areas, and columns, making it a handy solution for quick email template building.

Email Builder in Salesforce

Table structure

To ensure your email's appearance aligns with your expectations, it's recommended to structure emails using tables. Although this approach involves more complex code than using div elements, it guarantees compatibility across all mail clients. Make sure to apply all styles at the <td> level, as styles set elsewhere may not be supported in some browsers and mail clients.

Duplicate style properties

Certain CSS properties, like align, vertical-align, width, height, etc., should be defined twice. Include them in the CSS style for most mail clients and separately on the <td> element for mail clients like Outlook.

For example:

<td style="width:150px; height: 100%; vertical-align: middle" width="150" height="100%" valign="middle">
Enter fullscreen mode Exit fullscreen mode

Note that for properties with px values, we write only the number (e.g., width="150"). For percent values, we add a percent sign.

Use only supported properties

Keep in mind that even popular mail clients may have limited or no support for certain HTML or CSS properties. Be cautious when using elements and properties, ensuring they are supported in your recipients' mail clients. You can check each property's support for the most popular email clients on the CanIEmail website.

For example, the border-radius property that creates rounded corners on buttons:

border-radius in CanIEmail

Avoid VML in your templates

While creating adaptive email templates, you might come across VML (Vector Markup Language), a code format used to create graphics and visual elements, which allows adding interactive elements and custom background images to make email campaigns more engaging. However, it's important to note that VML is not supported in Salesforce email templates. If you attempt to use VML, it will be deleted when you save the email template. Therefore, it's best to avoid VML and explore alternative solutions to achieve your desired design and interactivity.

Simplify editing with a developer console

While making style adjustments in Salesforce's email templates, you can switch views by clicking the Source button to see the HTML code.

Source button
However, to view applied style changes in real-time, use the built-in browser's Developer Console. Any changes made there will be applied to the email template when saving and won't be overwritten by styles set in the Source tab.

Dev console save

Disable text editing extensions

If you use text editing extensions in your browser, such as Grammarly or QuillBot, be mindful that they may add elements or logos to your email template automatically. In Salesforce these elements can be saved as a part of your email template and your recipients will receive them by mistake. Ensure that the final version of your email template doesn't include any extra symbols, images, or unexpected elements.

Summary

To sum up, Salesforce allows an extensive functionality in using and creating email templates. Just sometimes you need to know its limitations and features to be like a Pro.
Have some valuable insights or nifty tricks for working with Salesforce Email Templates? Drop them in the comments below, and let's exchange our knowledge!

If you've found this article informative and useful, I'd love to connect with you on LinkedIn. Building a network of like-minded Salesforce enthusiasts is always exciting. Feel free to reach out with any questions or feedback about the article. I'm here to engage in a conversation and provide further assistance. Let's connect and continue learning and growing together in the Salesforce community!

Top comments (0)