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

EmailFileAttachment Constructors

The following are constructors for EmailFileAttachment.

EmailFileAttachment()

Creates a new instance of the Messaging.EmailFileAttachment class.

Signature

public EmailFileAttachment()

EmailFileAttachment Methods

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

setBody(attachment)

Sets the attachment itself.

Signature

public Void setBody(Blob attachment)

Parameters

attachment
Type: Blob

Return Value

Type: Void

setContentType(contentType)

Sets the attachment's Content-Type.

Signature

public Void setContentType(String contentType)

Parameters

contentType
Type: String

Return Value

Type: Void

setFileName(fileName)

Sets the name of the file to attach.

Signature

public Void setFileName(String fileName)

Parameters

fileName
Type: String

Return Value

Type: Void

setInline(isInline)

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

Signature

public Void setInline(Boolean isInline)

Parameters

isInline
Type: Boolean

Return Value

Type: Void

Usage

In most cases, inline content is displayed to the user when the message is opened. Attachment content requires user action to be displayed.