Attachment

public struct Attachment

Presentation an attachement contained in a Mail.

  • Properties when the attachment is a file.

    See more

    Declaration

    Swift

    public struct FileProperty
  • Properties when the attachment is an HTML string.

    See more

    Declaration

    Swift

    public struct HTMLProperty
  • Properties when the attachment is some raw data.

    See more

    Declaration

    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.
    See more

    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 related ones will be contained in a related 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

    filePath

    Path in the local disk of the file.

    mime

    MIME 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 type application/octet-stream will be used.

    name

    File name which will be presented in the mail. Default is the file name from filePath.

    inline

    Whether the file could be inline or not. When set to true, the attachment “Content-Disposition” header will be inline, otherwise it will be attachment. If you want to embed the file in mail content, set it to true. Otherwise if you need it to be a standalone attachment, false.

    additionalHeaders

    Additional headers when sending current attachment with a Mail.

    related

    Related attachments of current attachment. The related ones will be contained in a related 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

    data

    Raw data will be sent as attachment.

    mime

    MIME type of the data.

    name

    File name which will be presented in the mail.

    inline

    Whether the file could be inline or not. When set to true, the attachment “Content-Disposition” header will be inline, otherwise it will be attachment. If you want to embed the file in mail content, set it to true. Otherwise if you need it to be a standalone attachment, false.

    additionalHeaders

    Additional headers when sending current attachment with a Mail.

    related

    Related attachments of current attachment. The related ones will be contained in a related 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

    htmlContent

    Content string of HTML.

    characterSet

    Charater encoding set of htmlContent. Default is utf-8.

    alternative

    Whether this HTML could be alternative for plain text. Default is true, means the HTML content could be alternative for plain text.

    inline

    Whether the HTML could be inline or not. Default is true.

    additionalHeaders

    Additional headers when sending current attachment with a Mail.

    related

    Related attachments of current attachment. The related ones will be contained in a related boundary in the mail body.

  • Initilize an attachment with an AttachmentType.

    Declaration

    Swift

    public init(type: AttachmentType,
                    additionalHeaders: [String: String] = [:],
                    related: [Attachment] = [])

    Parameters

    type

    The type of attachement.

    additionalHeaders

    Additional headers when sending current attachment with a Mail.

    related

    Related attachments of current attachment. The related ones will be contained in a related boundary in the mail body.

  • Whether two Attachment should equal. Two Attachment will equal to each other when all members equal.

    Declaration

    Swift

    public static func ==(lhs: Attachment, rhs: Attachment) -> Bool

    Parameters

    lhs

    Left hand Attachment.

    rhs

    Right hand Attachment

    Return Value

    true if two attachments equal. Otherwise, false.