I want to use custom labels in the email template to display images stored in the documents.
I want to store the base URl and Ids in a label so that I can fix them on moving them to other sandboxes.
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.
Sign up to join this communityI want to use custom labels in the email template to display images stored in the documents.
I want to store the base URl and Ids in a label so that I can fix them on moving them to other sandboxes.
Use below syntax to get the custom label in the Email Template, Please remember to enclose the syntax with single quote(').
'{!$Label.LabelName}'
You have to use VisualForce HTML template. Here's how to use it:
Suppose in the template, the Billing Address is written as follows:
<apex:variable var="billingAddress" value="Billing Address" />
To use the label change this to:
<apex:variable var="billingAddress" value="{!$Label.BillingAddress}"/>
As another example, you can change a literal value within the Visualforce markup like this:
<td>My Label</td>
To use a created label called MyLabel, instead of a literal, change this to:
<td>{!Label.MyLabel}</td>
And this should work fine!
You can use this format to use custom labels in the classic email templates.
{!$Label.put_your_label_api}
But to use images in the email you can create a formula field in which you can use this below formula and pass the url of image where it is publicly hosted.
IMAGE(image_url, alternate_text [, height, width])