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.

This type extends Metadata and inherits its fields.

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

Introduced in API version 49.0.

  • Type: ApexEmailNotification[]
  • Required: No
  • Description: A specific Apex email notification. You can specify multiple notifications.

Represents an Apex email notification.

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

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

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

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.

This example uses a wildcard in package.xml.

This sample deploys an Apex email notification that notifies a Salesforce user in the org.

This sample deploys an Apex email notification that notifies an external email address.

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.

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.

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.