Apex Exception Email in Salesforce

Apex Exception Email in Salesforce

Set the email addresses that receive notifications when your Apex code encounters unhandled exceptions. Emails can be sent to your Salesforce org’s users and to external email addresses.

Salesforce sends two types of notification mails when potential issues with APEX code are detected:

APEX warning mails, which are sent when a class or trigger exceeds 50% of an APEX governor limit
APEX exception mails, which are sent when an unhandled exception occurs in a trigger or class

1. Go to Email –> Apex Exception Email.

2. Click Add Salesforce user to add user to start receiving exception or add External Address in Email Addresses Not in Salesforce section.

4 thoughts on “Apex Exception Email in Salesforce

  • Hello,

    Can we query this Apex Exception Email in apex(code). Use this email to send mail from catch block if some error occurs in our code?
    Idea is send custom exception email from code & want to use this (Apex Exception Email) email id in code.
    Thanks

  • List listRecipients = [SELECT UserId, User.Email, Email FROM ApexEmailNotification];
    Set recipients = new Set();
    for (ApexEmailNotification element : listRecipients ){
    if(element.Email != null)
    {
    recipients.add(element.Email);
    } else if (element.UserId != null) {
    recipients.add(element.User.Email);
    }
    }

Leave a Reply