---
schema_version: "1"
id: e1816f0ac1daa09cfa33c5b7d1e330104cc7c53a1e5e0dd4dc253cec9e091da4
title: EmailFileAttachment Class
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexref/apex_classes_email_outbound_attachment.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_classes_email_outbound_attachment.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 8175b48b09f48ce5e4b41ddfe1db1099b55ca961fcc29eaddb56de2e0074acf3
description: EmailFileAttachment is used in SingleEmailMessage to specify attachments passed in as part of the request, as opposed to existing documents in Salesforce.Creates a new instance of the Messaging.EmailFileAttachment class.Gets or sets the attachment itself.Gets or sets the attachment's Content-Type.Gets or sets the name of the file to attach.Read-Only. Gets the attachment ID.Specifies a Content-Disposition of inline (true) or attachment (false).
---
# EmailFileAttachment Class

EmailFileAttachment is used in SingleEmailMessage to specify attachments passed in as part of the request, as opposed to existing documents in Salesforce.

## 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).

- **[EmailFileAttachment Constructors](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_classes_email_outbound_attachment.htm#apex_Messaging_EmailFileAttachment_constructors)**
- **[EmailFileAttachment Properties](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_classes_email_outbound_attachment.htm#apex_Messaging_EmailFileAttachment_properties)**

## EmailFileAttachment Constructors

The following are constructors for EmailFileAttachment.

- **[EmailFileAttachment()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_classes_email_outbound_attachment.htm#apex_Messaging_EmailFileAttachment_ctor)**  
    Creates a new instance of the Messaging.EmailFileAttachment class.

### EmailFileAttachment()

Creates a new instance of the Messaging.EmailFileAttachment class.

#### Signature

public EmailFileAttachment()

## EmailFileAttachment Properties

The following are properties for EmailFileAttachment.

- **[body](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_classes_email_outbound_attachment.htm#apex_Messaging_EmailFileAttachment_body)**  
    Gets or sets the attachment itself.
- **[contenttype](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_classes_email_outbound_attachment.htm#apex_Messaging_EmailFileAttachment_contenttype)**  
    Gets or sets the attachment's Content-Type.
- **[filename](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_classes_email_outbound_attachment.htm#apex_Messaging_EmailFileAttachment_filename)**  
    Gets or sets the name of the file to attach.
- **[id](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_classes_email_outbound_attachment.htm#apex_Messaging_EmailFileAttachment_id)**  
    Read-Only. Gets the attachment ID.
- **[inline](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_classes_email_outbound_attachment.htm#apex_Messaging_EmailFileAttachment_inline)**  
    Specifies a Content-Disposition of inline (true) or attachment (false).

### body

Gets or sets the attachment itself.

#### Signature

public Blob body {get; set;}

#### Property Value

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

### contenttype

Gets or sets the attachment's Content-Type.

#### Signature

public String contenttype {get; set;}

#### Property 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.")

### filename

Gets or sets the name of the file to attach.

#### Signature

public String filename {get; set;}

#### Property 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.")

### id

Read-Only. Gets the attachment ID.

#### Signature

public Id id {get;}

#### Property Value

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

### inline

Specifies a Content-Disposition of inline (true) or attachment (false).

#### Signature

public Boolean inline {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.")