---
schema_version: "1"
id: 01482597fd783206bda9ceb2ad2ccac9e4c94c8a88978d76388738f6ac833c8a
title: SendEmailError Class
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexref/apex_classes_email_outbound_sendemailerror.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_classes_email_outbound_sendemailerror.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 821bb18d4bd3e9071398738fb21f2ca4b357eadf574ce092f4931f123b292668
description: Represents an error that the SendEmailResult object may contain.A list of one or more field names. Identifies which fields in the object, if any, affected the error condition.The text of the error message. Returns a code that characterizes the error.The ID of the target record for which the error occurred.
---
# SendEmailError Class

Represents an error that the SendEmailResult object may contain.

## Namespace

[Messaging](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_Messaging.htm "The Messaging namespace provides classes and methods for Salesforce notifications and email functionality.")

## Usage

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

#### Important

Sending an email by using Apex requires domain-level and user-level email verification. System-generated emails also require verification of the From email address. Email delivery fails if any of these verifications is incomplete. See [Requirements to Send Email from Salesforce](https://help.salesforce.com/s/articleView?id=xcloud.security_email_verification_requirements.htm&language=en_US&type=5).

## SendEmailError Methods

The following are methods for SendEmailError. All are instance methods.

- **[getFields()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_classes_email_outbound_sendemailerror.htm#apex_Messaging_SendEmailError_getFields)**  
    A list of one or more field names. Identifies which fields in the object, if any, affected the error condition.
- **[getMessage()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_classes_email_outbound_sendemailerror.htm#apex_Messaging_SendEmailError_getMessage)**  
    The text of the error message.
- **[getStatusCode()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_classes_email_outbound_sendemailerror.htm#apex_Messaging_SendEmailError_getStatusCode)**  
    Returns a code that characterizes the error.
- **[getTargetObjectId()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_classes_email_outbound_sendemailerror.htm#apex_Messaging_SendEmailError_getTargetObjectId)**  
    The ID of the target record for which the error occurred.

### getFields()

A list of one or more field names. Identifies which fields in the object, if any, affected the error condition.

#### Signature

public String\[\] getFields()

#### Return Value

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

### getMessage()

The text of the error message.

#### Signature

public String getMessage()

#### Return Value

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

### getStatusCode()

Returns a code that characterizes the error.

#### Signature

public System.StatusCode getStatusCode()

#### Return Value

Type: System.StatusCode

#### Usage

The full list of status codes is available in the WSDL file for your organization. For more information about accessing the WSDL file for your organization, see Downloading Salesforce WSDLs and Client Authentication Certificates in the Salesforce online help.

### getTargetObjectId()

The ID of the target record for which the error occurred.

#### Signature

public String getTargetObjectId()

#### Return Value

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