Attachment
open class Attachment : Encodable
The Attachment class represents a file to attach to an email.
-
The content, or data, of the attachment.
Declaration
Swift
public let content: Data -
The filename of the attachment.
Declaration
Swift
public let filename: String -
The content (or MIME) type of the attachment.
Declaration
Swift
public let type: ContentType? -
The content-disposition of the attachment specifying how you would like the attachment to be displayed. For example,
inline
results in the attached file being displayed automatically within the message whileattachment
results in the attached file requiring some action to be taken before it is displayed (e.g. opening or downloading the file).Declaration
Swift
public let disposition: ContentDisposition -
A unique id that you specify for the attachment. This is used when the disposition is set to
inline
and the attachment is an image, allowing the file to be displayed within the body of your email. Ex:<img src="cid:ii_139db99fdb5c3704"></img>Declaration
Swift
public let contentID: String?
-
Initializes the attachment.
Declaration
Swift
public init(filename: String, content: Data, disposition: ContentDisposition = .attachment, type: ContentType? = nil, contentID: String? = nil)Parameters
filenameThe filename of the attachment.
contentThe data of the attachment.
dispositionThe content-disposition of the attachment (defaults to
ContentDisposition.Attachment).typeThe content-type of the attachment.
contentIDThe CID of the attachment, used to show the attachments inline with the body of the email.
-
Validates that the content type of the attachment is correct.
Declaration
Swift
open func validate() throws
View on GitHub
Attachment Class Reference