4

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.

3
  • What is the type of your email template? Is it a VF template?
    – manjit5190
    Oct 14, 2015 at 19:39
  • 2
    Only VF templates can have CL.
    – Ashwani
    Oct 15, 2015 at 6:52
  • It is an HTML template. Oct 15, 2015 at 20:23

3 Answers 3

8

Use below syntax to get the custom label in the Email Template, Please remember to enclose the syntax with single quote(').

'{!$Label.LabelName}'
4
  • I don't know why this answer is down-voted. Perhaps it didn't work in 2016? But it does work now. You can use {!$Label.LabelName} in text/html classic email templates in Winter 19
    – Aidan
    Jan 31, 2019 at 17:13
  • Was able to use the label without the single quote in the subject line. Thanks for the tip! Mar 7, 2019 at 19:41
  • unable to use {!$Label.LabelName}' with or without quotes in body of classic email template
    – C0DEPirate
    Mar 26, 2019 at 15:37
  • I can't get the label to work in the body of the email by itself. It does work in the subject and it does work in the URL of a link merge field. But whenever I use it by itself in the body the merge field gets replaced with blank text. I tried with and without the single quotes. Sep 3, 2019 at 8:47
3

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!

1

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])

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.