---
schema_version: "1"
id: d9f082e2fe6f36c44ccc82c565ac9759179d21bb7860eb77e945ad51cd4a3f8e
title: DmlOptions.EmailHeader Class
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexref/apex_class_Database_EmailHeader.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Database_EmailHeader.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: f7b1f43828c6c50c5b468a285dde23c5410f9b19f1d7335ba94c9145ebdd8a74
description: Enables setting email options.Indicates whether to trigger auto-response rules (true) or not (false), for leads and cases.Indicates whether to trigger email outside the organization (true) or not (false).Indicates whether to trigger email that is sent to users in the organization (true) or not (false).
---
# DmlOptions.EmailHeader Class

Enables setting email options.

## Namespace

[Database](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_Database.htm "The Database namespace provides classes used with DML operations.")

## Usage

Even though auto-sent emails can be triggered by actions in the Salesforce user interface, the DMLOptions settings for emailHeader take effect only for DML operations carried out in Apex code.

## Example

In the following example, the triggerAutoResponseEmail option is specified:

Account a = new Account(name='Acme Plumbing');
    
    insert as user a;
    
    Contact c = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber', accountid=a.id);
    
    insert as user c;
    
    Database.DMLOptions dlo = new Database.DMLOptions();
    
    dlo.EmailHeader.triggerAutoResponseEmail = true;
    
    Case ca = new Case(subject='Plumbing Problems', contactid=c.id);
    
    database.insert(ca, dlo, AccessLevel.USER\_MODE);
   

Suppose that you use an after-insert or after-update trigger to change ownership of leads, contacts, or opportunities. If you use the API to change record ownership, or if a Lightning Experience user changes a record’s owner, no email notification is sent. To send email notifications to a record’s new owner, set the triggerUserEmail property to true.

## DmlOptions.EmailHeader Properties

The following are properties for DmlOptions.EmailHeader.

- **[triggerAutoResponseEmail](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Database_EmailHeader.htm#apex_Database_EmailHeader_triggerAutoResponseEmail)**  
    Indicates whether to trigger auto-response rules (true) or not (false), for leads and cases.
- **[triggerOtherEmail](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Database_EmailHeader.htm#apex_Database_EmailHeader_triggerOtherEmail)**  
    Indicates whether to trigger email outside the organization (true) or not (false).
- **[triggerUserEmail](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Database_EmailHeader.htm#apex_Database_EmailHeader_triggerUserEmail)**  
    Indicates whether to trigger email that is sent to users in the organization (true) or not (false).

### triggerAutoResponseEmail

Indicates whether to trigger auto-response rules (true) or not (false), for leads and cases.

#### Signature

public Boolean triggerAutoResponseEmail {get; set;}

#### Property Value

Type: [Boolean](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_boolean.htm#apex_methods_system_boolean "Contains methods for the Boolean primitive data type.")

#### Usage

This email can be automatically triggered by a number of events, for example creating a case or resetting a user password. If this value is set to true, when a case is created, if there is an email address for the contact specified in ContactID, the email is sent to that address. If not, the email is sent to the address specified in SuppliedEmail

### triggerOtherEmail

Indicates whether to trigger email outside the organization (true) or not (false).

#### Signature

public Boolean triggerOtherEmail {get; set;}

#### Property Value

Type: [Boolean](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_boolean.htm#apex_methods_system_boolean "Contains methods for the Boolean primitive data type.")

#### Usage

This email can be automatically triggered by creating, editing, or deleting a contact for a case.

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

#### Note

Email sent through Apex because of a group event includes additional behaviors. A group event is an event for which IsGroupEvent is true. The EventAttendee object tracks the users, leads, or contacts that are invited to a group event. Note the following behaviors for group event email sent through Apex:

- Sending a group event invitation to a lead or contact respects the triggerOtherEmail option
- Email sent when updating or deleting a group event also respects the triggerUserEmail and triggerOtherEmail options, as appropriate

### triggerUserEmail

Indicates whether to trigger email that is sent to users in the organization (true) or not (false).

#### Signature

public Boolean triggerUserEmail {get; set;}

#### Property Value

Type: [Boolean](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_boolean.htm#apex_methods_system_boolean "Contains methods for the Boolean primitive data type.")

#### Usage

This email can be automatically triggered by a number of events; resetting a password, creating a new user, or creating or modifying a task.

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

#### Note

Adding comments to a case in Apex doesn’t trigger email to users in the organization even if triggerUserEmail is set to true.

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

#### Note

Email sent through Apex because of a group event includes additional behaviors. A group event is an event for which IsGroupEvent is true. The EventAttendee object tracks the users, leads, or contacts that are invited to a group event. Note the following behaviors for group event email sent through Apex:

- Sending a group event invitation to a user respects the triggerUserEmail option
- Email sent when updating or deleting a group event also respects the triggerUserEmail and triggerOtherEmail options, as appropriate