---
schema_version: "1"
id: 30d729575bc89b72ff5793fb740f3588eb1e4849f98fe4151b96901aed366b15
title: EmailTemplate
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/object_reference/sforce_api_objects_emailtemplate.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_emailtemplate.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 0144913d9ee83841fe695dab88d3612abcb274e991cf693014dc3b32ce251f7b
description: Represents a template for an email, mass email, list email, or Sales Engagement email. Supported in first-generation managed packages only.
---
# EmailTemplate

Represents a template for an email, mass email, list email, or Sales Engagement email. Supported in first-generation managed packages only.

![Note](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/images/icon_note.png)

#### Note

You can’t send a mass email using a Visualforce email template.

## Supported Calls

create(), delete(), describeLayout(), describeSObjects(), getDeleted(), getUpdated(), query(), retrieve(), search(), update(), upsert()

## Special Access Rules

Customer Portal users can’t access this object.

## Fields

| Field | Details |
| --- | --- |
| ApiVersion | 
Type

double

Properties

Create, Filter, Nillable, Sort, Update

Description

The API version for this class. Every class has an API version specified at creation.



 |
| Body | 

Type

textarea

Properties

Create, Nillable, Update

Description

Content of the email. Limit: 384 KB.



 |
| BrandTemplateId | 

Type

reference

Properties

Create, Filter, Group, Nillable, Sort, Update

Description

Required. ID of the BrandTemplate associated with this email template. The brand template supplies letterhead information for the email template.



 |
| DeliveryRate | 

Type

percent

Properties

Filter, Nillable, Sort

Description

Read-only. The percentage of the emails that were delivered compared to the number that bounced (soft and hard). Note: this data includes emails that were delivered to the recipient's spam folder.

This field is available in API version 46.0 and later. To access this field, your org must use Sales Engagement and users need the Sales Engagement User or Sales Engagement Cadence Creator permission set. This field value includes emails sent via the ListEmail object or Sales Engagement cadences.





 |
| Description | 

Type

string

Properties

Create, Filter, Nillable, Sort, Update

Description

Description of the template, for example, Promotion Mass Mailing.



 |
| DeveloperName | 

Type

string

Properties

Create, Defaulted on create, Filter, Group, Sort, Update

Description

The unique name of the object in the API. This name can contain only underscores and alphanumeric characters, and must be unique in your org. It must begin with a letter, not include spaces, not end with an underscore, and not contain two consecutive underscores. In managed packages, this field prevents naming conflicts on package installations. With this field, a developer can change the object’s name in a managed package and the changes are reflected in a subscriber’s organization. Label is **Template Unique Name**.

![Note](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/images/icon_note.png)

#### Note

When creating large sets of data, always specify a unique DeveloperName for each record. If no DeveloperName is specified, performance may slow while Salesforce generates one for each record.















 |
| Encoding | 

Type

picklist

Properties

Create, Filter, Group, Nillable, Restricted picklist, Sort, Update

Description

Character set encoding for the template.



 |
| EnhancedLetterheadId | 

Type

reference

Properties

Create, Filter, Group, Nillable, Sort, Update

Description

ID of the enhanced letterhead associated with the email template.

![Note](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/images/icon_note.png)

#### Note

To use an enhanced letterhead, associate it with a Lightning email template that uses the HML merge language.

This is a relationship field.

Relationship Name

EnhancedLetterhead

Relationship Type

Lookup

Refers To

EnhancedLetterhead



 |
| EntityType | 

Type

picklist

Properties

Create, Filter, Group, Restricted picklist, Sort,

Description

When UIType is 2 (Lightning Experience) or 3 (Lightning ExperienceSample), EntityType indicates which entities this template can be used with (for example, account or lead). Valid values are standard object ID prefixes: 001 for account, 003 for contact, 006 for opportunity, and 00Q for lead, 500 for case, and 701 for campaign.

This field has been removed in API version 39.0. Use RelatedEntityType instead.



 |
| FolderId | 

Type

reference

Properties

Create, Filter, Group, Sort, Update

Description

ID of the folder that contains the template.

This is a relationship field.

Relationship Name

Folder

Relationship Type

Lookup

Refers To

Folder, Organization, User



 |
| FolderName | 

Type

string

Properties

Filter, Nillable, Sort

Description

The name of the folder that contains the template.



 |
| HasSalesforceFiles | 

Type

boolean

Properties

Defaulted on create, Filter, Group, Sort

Description

If the email template has attachments from Salesforce Files. The default value is false.



 |
| HtmlValue | 

Type

textarea

Properties

Create, Nillable, Update

Description

This field contains the content of the email message, including HTML coding to render the email message. Limit: 384 KB.



 |
| IsActive | 

Type

boolean

Properties

Create, Defaulted on create, Filter, Group, Sort, Update

Description

Indicates that this template is active if true, or inactive if false.



 |
| IsBuilderContent | 

Type

boolean

Properties

Defaulted on create, Filter, Group, Sort

Description

If the email template was made in Email Template Builder. The default value is false.



 |
| LastUsedDate | 

Type

dateTime

Properties

Filter, Nillable, Sort

Description

Date and time when this email template was last used.

Used with Salesforce Classic templates.

Not typically used with Lightning Experience templates.



 |
| Markup | 

Type

textarea

Properties

Create, Nillable, Update

Description

The Visualforce markup, HTML, JavaScript, or any other Web-enabled code that defines the content of the template.



 |
| Name | 

Type

string

Properties

Create, Filter, Group, idLookup, Sort, Update

Description

Name of the template. Label is **Email Template Name**.



 |
| NamespacePrefix | 

Type

string

Properties

Filter, Group, Nillable, Sort

Description

The namespace prefix that is associated with this object. Each Developer Edition org that creates a managed package has a unique namespace prefix. Limit: 15 characters. You can refer to a component in a managed package by using the namespacePrefix\_\_componentName notation.

The namespace prefix can have one of the following values.

- In Developer Edition orgs, NamespacePrefix is set to the namespace prefix of the org for all objects that support it, unless an object is in an installed managed package. In that case, the object has the namespace prefix of the installed managed package. This field’s value is the namespace prefix of the Developer Edition org of the package developer.
- In orgs that are not Developer Edition orgs, NamespacePrefix is set only for objects that are part of an installed managed package. All other objects have no namespace prefix.

This field can’t be accessed unless the logged-in user has the Customize Application permission.





 |
| OwnerId | 

Type

reference

Properties

Create, Defaulted on create, Filter, Group, Sort, Update

Description

ID of the owner of the template.

This is a relationship field.

Relationship Name

Owner

Relationship Type

Lookup

Refers To

User



 |
| RelatedEntityType | 

Type

picklist

Properties

Create, Filter, Group, Nillable, Restricted picklist, Sort, Update

Description

When UIType is 2 (Lightning Experience) or 3 (Lightning ExperienceSample), RelatedEntityType indicates which entities this template can be used with. Valid values are the entity API name: "Account" for account, "Contact" for contact, "Opportunity" for opportunity, "Lead" for lead, and so on. The value can be any entity the user has read access to (including custom entities) but not virtual entities, setup entities, or platform entities.

No restrictions exist at the schema level.



 |
| Subject | 

Type

string

Properties

Create, Nillable, Sort, Update

Description

Content of the subject line.

The limit is 1,000 characters for Lightning email templates and 230 characters for Classic email templates.



 |
| TemplateStyle | 

Type

picklist

Properties

Create, Filter, Group, Restricted picklist, Sort

Description

Style of the template.

Possible values are:

- formalLetter—Formal Letter
- freeForm—Free Form Letter
- newsletter—Newsletter
- none—No Email Layout
- products—Products
- promotionLeft—Promotion (Left)
- promotionRight—Promotion (Right)





 |
| TemplateType | 

Type

picklist

Properties

Create, Filter, Group, Restricted picklist, Sort

Description

Type of template.

Possible values are:

- custom—Custom
- html—HTML
- text—Text
- visualforce—Visualforce





 |
| TimesUsed | 

Type

int

Properties

Filter, Group, Nillable, Sort

Description

Number of times this email template has been used.

Used with Salesforce Classic templates.

Not typically used with Lightning Experience templates.



 |
| TotalDelivered | 

Type

int

Properties

Filter, Group, Nillable, Sort

Description

Read-only. The total number of emails sent minus hard and soft bounces. Note: this data includes emails that were delivered to the recipient's spam folder.

This field is available in API version 46.0 and later. To access this field, your org must use Sales Engagement and users need the Sales Engagement User or Sales Engagement Cadence Creator permission set. This field value includes emails sent via the ListEmail object or Sales Engagement cadences.





 |
| TotalHardBounced | 

Type

int

Properties

Defaulted on create, Filter, Group, Nillable, Sort

Description

Read-only. The total number of emails that permanently bounced back to the sender because the address is invalid. A hard bounce can occur because the domain name doesn't exist or because the recipient is unknown.

This field is available in API version 46.0 and later. To access this field, your org must use Sales Engagement and users need the Sales Engagement User or Sales Engagement Cadence Creator permission set. This field value includes emails sent via the ListEmail object or Sales Engagement cadences.





 |
| TotalOpens | 

Type

int

Properties

Defaulted on create, Filter, Group, Nillable, Sort

Description

Read-only. The total number of times a prospect’s email client loaded the images in the HTML version of the email. We also record an open if the prospect clicks a link within the HTML or text email without downloading images. A click indicates that they viewed the message. Some email clients (Outlook, Apple Mail, Thunderbird) don’t display images by default. Pardot counts an open each time the images load.

This field is available in API version 46.0 and later. To access this field, your org must use Sales Engagement and users need the Sales Engagement User or Sales Engagement Cadence Creator permission set. This field value includes emails sent via the ListEmail object or Sales Engagement cadences.





 |
| TotalSent | 

Type

int

Properties

Filter, Group, Nillable, Sort

Description

Read-only. The total number of emails sent, including bounced, opted-out, and invalid To: addresses.

This field is available in API version 46.0 and later. To access this field, your org must use Sales Engagement and users need the Sales Engagement User or Sales Engagement Cadence Creator permission set. This field value includes emails sent via the ListEmail object or Sales Engagement cadences.





 |
| TotalSoftBounced | 

Type

int

Properties

Defaulted on create, Filter, Group, Nillable, Sort

Description

Read-only. The total number of times a recipient’s mail server acknowledged the email, but returned it to the sender. Sometimes it is because the recipient's mailbox is full or the mail server is temporarily unavailable. A soft bounce message can sometimes be delivered at another time. After 5 soft bounces, Pardot opts the prospect out of emails.

This field is available in API version 46.0 and later. To access this field, your org must use Sales Engagement and users need the Sales Engagement User or Sales Engagement Cadence Creator permission set. This field value includes emails sent via the ListEmail object or Sales Engagement cadences.





 |
| UIType | 

Type

picklist

Properties

Create, Defaulted on create, Filter, Group, Nillable, Restricted picklist, Sort, Update

Description

Indicates the user interface where this template is usable.

Possible values are:

- Aloha
- SFX
- SFX\_Sample—SFXSample





 |

## Usage

To retrieve this object, issue a describe call on an object, which returns a query result for each activity since the object was created. You can't query these records.

## Associated Objects

This object has the following associated objects. If the API version isn’t specified, they’re available in the same API versions as this object. Otherwise, they’re available in the specified API version and later.

[EmailTemplateChangeEvent](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_associated_objects_change_event.htm "A ChangeEvent object is available for each object that supports Change Data Capture. You can subscribe to a stream of change events using Change Data Capture to receive data tied to record changes in Salesforce. Changes include record creation, updates to an existing record, deletion of a record, and undeletion of a record. A change event isn’t a Salesforce object—it doesn’t support CRUD operations or queries. It’s included in the object reference so you can discover which Salesforce objects support change events.") (API version 48.0)

Change events are available for the object.

#### See Also

- [Attachment](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_attachment.htm#sforce_api_objects_attachment "Represents a file that a User has uploaded and attached to a parent object.")
- [EmailStatus](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_emailstatus.htm "Represents the status of email sent.")
- [DocumentAttachmentMap](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_documentattachmentmap.htm#sforce_api_objects_documentattachmentmap "Maps the relationship between an EmailTemplate and its attachment, which is stored as a Document.")