You are here:
Considerations for Using Merge Fields in Email Templates and Letterheads
A merge field is a placeholder used in an email, a letterhead, a mail merge template, a custom link, or a formula to incorporate values from a record. When you send the email, the placeholder is replaced with the data from the record or records of the people you’re emailing.
Required Editions
In Summer ‘18, we introduced the Handlebars Merge Language (HML) for email templates in Lightning Experience. If your email template has merge fields with three curly braces ({{{), you’re using an HML email template. If the merge fields have one curly brace ({), or an exclamation mark (!), you’re using a SML (Salesforce Merge Language) email template. Lightning templates created since Summer ‘18 are HML email templates.
- The Recipient merge field isn’t supported in email templates used for automations.
- The Created Date and Last Modified Date fields display the date only, not the date and time.
- If your template contains a merge field for which a record has no data, that field doesn’t appear in the email you send.
- Give objects and fields unique names and labels. If two or more custom objects have matching names or labels, only one of the objects appears when you select from available merge fields. For example, an object has two fields have the same name, and one field is custom and the other isn't. Create an email template with either or both of the merge fields. The merge fields always resolve to the value of the custom field.
- Merge fields have no value if they’re defined for an object that doesn't match the recipient or related to record.
- When using the Recipient merge field in a Lightning email template in the Email Composer, the data for the first recipient in the To: field is used. When using list email, the Recipient merge field gets the data for each recipient as Salesforce sends out individual emails in bulk.
- In Enhanced letterheads, only the Handlebars Merge Language and global merge fields are supported.
- If you forward or reply to an email, and the email includes characters from Salesforce merge field syntax, those characters are ignored. They aren't resolved as if they are merge fields. Instead, the email reply preserves the unresolved text and ensures that it can’t be confused with Salesforce merge fields. Correctly formatted merge fields included in forwarded or reply-to emails are resolved normally.
- The Subject field has a limit of 1,000 characters in Lightning Experience and 230 characters in Salesforce Classic. Merge fields use hidden encoding characters that count against the character limit. If the field exceeds the character limit, we remove excess characters from the end of the field.
See Also
- Use the Handlebars Merge Language in Lightning Email Templates, Enhanced Letterhead, and Email Template Builder
- Use the Salesforce Merge Language in Lightning Email Templates
- Use the Salesforce Merge Language in Classic Email Templates
- Merge Fields for Experience Cloud Sites
- Customize Email Sent from Experience Cloud Sites for Email Verification

