Attachment
public struct Attachment
Presentation an attachement contained in a Mail.
-
Properties when the attachment is a file.
See moreDeclaration
Swift
public struct FileProperty -
Properties when the attachment is an HTML string.
See moreDeclaration
Swift
public struct HTMLProperty -
Properties when the attachment is some raw data.
See moreDeclaration
Swift
public struct DataProperty -
Attachment type.
- file: The attachment is a file in local disk.
- html: The attachment is an HTML string.
- data: The attachment is some raw data.
Declaration
Swift
public enum AttachmentType -
The type of current attachment.
Declaration
Swift
public let type: AttachmentType -
Additional headers when sending current attachment with a
Mail.Declaration
Swift
public let additionalHeaders: [String: String] -
Related attachments of current attachment. The
relatedones will be contained in arelated
boundary in the mail body.Declaration
Swift
public let related: [Attachment] -
Whether this attachment is an alternative one.
Declaration
Swift
public var isAlternative: Bool -
Initilize a file attachment.
Declaration
Swift
public init(filePath: String, mime: String? = nil, name: String? = nil, inline: Bool = false, additionalHeaders: [String: String] = [:], related: [Attachment] = [])Parameters
filePathPath in the local disk of the file.
mimeMIME type of the file. Default is
nil, which means leave to Hedwig to guess the type from file extension. If Hedwig can not determine the MIME type, a general binary typeapplication/octet-stream
will be used.nameFile name which will be presented in the mail. Default is the file name from
filePath.inlineWhether the file could be inline or not. When set to
true, the attachment “Content-Disposition” header will beinline, otherwise it will beattachment. If you want to embed the file in mail content, set it totrue. Otherwise if you need it to be a standalone attachment,false.additionalHeadersAdditional headers when sending current attachment with a
Mail.relatedRelated attachments of current attachment. The
relatedones will be contained in arelated
boundary in the mail body. -
Initilize a data attachment.
Declaration
Swift
public init(data: Data, mime: String, name: String, inline: Bool = false, additionalHeaders: [String: String] = [:], related: [Attachment] = [])Parameters
dataRaw data will be sent as attachment.
mimeMIME type of the data.
nameFile name which will be presented in the mail.
inlineWhether the file could be inline or not. When set to
true, the attachment “Content-Disposition” header will beinline, otherwise it will beattachment. If you want to embed the file in mail content, set it totrue. Otherwise if you need it to be a standalone attachment,false.additionalHeadersAdditional headers when sending current attachment with a
Mail.relatedRelated attachments of current attachment. The
relatedones will be contained in arelated
boundary in the mail body. -
Initilize an HTML attachment.
Declaration
Swift
public init(htmlContent: String, characterSet: String = "utf-8", alternative: Bool = true, inline: Bool = true, additionalHeaders: [String: String] = [:], related: [Attachment] = [])Parameters
htmlContentContent string of HTML.
characterSetCharater encoding set of
htmlContent. Default isutf-8
.alternativeWhether this HTML could be alternative for plain text. Default is
true, means the HTML content could be alternative for plain text.inlineWhether the HTML could be inline or not. Default is
true.additionalHeadersAdditional headers when sending current attachment with a
Mail.relatedRelated attachments of current attachment. The
relatedones will be contained in arelated
boundary in the mail body. -
Initilize an attachment with an
AttachmentType.Declaration
Swift
public init(type: AttachmentType, additionalHeaders: [String: String] = [:], related: [Attachment] = [])Parameters
typeThe type of attachement.
additionalHeadersAdditional headers when sending current attachment with a
Mail.relatedRelated attachments of current attachment. The
relatedones will be contained in arelated
boundary in the mail body.
-
Whether two
Attachment.FilePropertyshould equal. TwoAttachment.FilePropertywill equal to each other when all members equal.Declaration
Swift
public static func ==(lhs: Attachment.FileProperty, rhs: Attachment.FileProperty) -> BoolParameters
lhsLeft hand
FileProperty.rhsRight hand
FilePropertyReturn Value
trueif two file properties equal. Otherwise,false.
-
Whether two
Attachment.DataPropertyshould equal. TwoAttachment.DataPropertywill equal to each other when all members equal.Declaration
Swift
public static func ==(lhs: Attachment.DataProperty, rhs: Attachment.DataProperty) -> BoolParameters
lhsLeft hand
DataProperty.rhsRight hand
DataPropertyReturn Value
trueif two data properties equal. Otherwise,false.
-
Whether two
Attachment.HTMLPropertyshould equal. TwoAttachment.HTMLPropertywill equal to each other when all members equal.Declaration
Swift
public static func ==(lhs: Attachment.HTMLProperty, rhs: Attachment.HTMLProperty) -> BoolParameters
lhsLeft hand
HTMLProperty.rhsRight hand
HTMLPropertyReturn Value
trueif two HTML properties equal. Otherwise,false.
-
Whether two
Attachmentshould equal. TwoAttachmentwill equal to each other when all members equal.Declaration
Swift
public static func ==(lhs: Attachment, rhs: Attachment) -> BoolParameters
lhsLeft hand
Attachment.rhsRight hand
AttachmentReturn Value
trueif two attachments equal. Otherwise,false.
View on GitHub
Install in Dash
Attachment Struct Reference