2

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.

  • What is the type of your email template? Is it a VF template? – manjit5190 Oct 14 '15 at 19:39
  • 2
    Only VF templates can have CL. – Ashwani Oct 15 '15 at 6:52
  • It is an HTML template. – Keepcalmncode Oct 15 '15 at 20:23
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

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

'{!$Label.LabelName}'
  • 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 at 17:13
  • Was able to use the label without the single quote in the subject line. Thanks for the tip! – Jason Hardy Mar 7 at 19:41
  • unable to use {!$Label.LabelName}' with or without quotes in body of classic email template – C0DEPirate Mar 26 at 15:37

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.