Newer Version Available

This content describes an older version of this product. View Latest

ApexEmailNotifications

The ApexEmailNotifications type allows you to define users and email addresses that receive email for unhandled Apex errors. Flow errors can also use this metadata type.

Declarative Metadata File Suffix and Directory Location

The component filename is apexEmailNotifications.notifications. The Apex email notification file is stored in the apexEmailNotifications folder in the corresponding package directory.

Version

ApexEmailNotifications components are available in API version 49.0 and later.

Fields

Field Name Field Type Description
apexEmailNotification ApexEmailNotification A specific Apex email notification. You can specify multiple notifications.

ApexEmailNotification

Represents an Apex email notification.

Each ApexEmailNotification can contain an email or a user but not both.

Note

Field Name Field Type Description
email string The external email address to which the notification is sent. Mutually exclusive with the user field.
user string The username of the Salesforce user to be notified. Mutually exclusive with the email field.

Usage

Deploying ApexEmailNotifications deletes all previous notifications in the org. For example, consider two notifications, test1@example.com and test2@example.com, that are deployed in an org. When the following apexEmailNotifications.notifications is deployed, test1@example.com is deleted, because it's not in the deployed list.
1<?xml version="1.0" encoding="UTF-8"?>
2<ApexEmailNotifications xmlns="http://soap.sforce.com/2006/04/metadata">
3    <apexEmailNotification>
4        <email>test2@example.com</email>
5    </apexEmailNotification>
6</ApexEmailNotifications>

The ApexEmailNotifications metadata type isn't supported in destructiveChanges.xml. To delete specific ApexEmailNotification items, deploy a new ApexEmailNotifications without those items. To delete all Apex email notifications in an org, deploy an empty list of ApexEmailNotifications.

Note

Declarative Metadata Sample Definition

To deploy Apex email notifications, you can specify either the exact file name or use a wildcard in package.xml.

This example specifies the exact file name in package.xml.
1<?xml version="1.0" encoding="UTF-8"?>
2<Package xmlns="http://soap.sforce.com/2006/04/metadata">
3    <types>
4        <members>apexEmailNotifications</members>
5        <name>ApexEmailNotifications</name>
6    </types>
7    <version>49.0</version>
8</Package>
This example uses a wildcard in package.xml.
1<?xml version="1.0" encoding="UTF-8"?>
2<Package xmlns="http://soap.sforce.com/2006/04/metadata">
3    <types>
4        <members>*</members>
5        <name>ApexEmailNotifications</name>
6    </types>
7    <version>49.0</version>
8</Package>
This sample deploys an Apex email notification that notifies a Salesforce user in the org.
1<?xml version="1.0" encoding="UTF-8"?>
2<ApexEmailNotifications xmlns="http://soap.sforce.com/2006/04/metadata">
3    <apexEmailNotification>
4        <user>user1@example.com</user>
5    </apexEmailNotification>
6</ApexEmailNotifications>
This sample deploys an Apex email notification that notifies an external email address.
1<?xml version="1.0" encoding="UTF-8"?>
2<ApexEmailNotifications xmlns="http://soap.sforce.com/2006/04/metadata">
3    <apexEmailNotification>
4        <email>test@example.com</email>
5    </apexEmailNotification>
6</ApexEmailNotifications>

Wildcard Support in the Manifest File

This metadata type supports the wildcard character * (asterisk) in the package.xml manifest file. For information about using the manifest file, see Deploying and Retrieving Metadata with the Zip File.