Interface MailAttachment


  • public interface MailAttachment
    Represent a mail attachment that can be used in a MailMessage.
    Author:
    Alexander Lehmann, Lin Gao
    • Method Detail

      • create

        static MailAttachment create()
        construct an empty MailAttachment object that can be filled with the setters
      • create

        static MailAttachment create​(JsonObject json)
        create a MailAttachment object from a JsonObject representation
        Parameters:
        json - object to be copied
      • create

        static MailAttachment create​(MailAttachment other)
        create a copy of a MailAttachment object
        Parameters:
        other - object to be copied
      • getData

        Buffer getData()
        get the data
        Returns:
        the data
      • setData

        MailAttachment setData​(Buffer data)
        set the data
        Parameters:
        data - Buffer of bytes to be used at attachment
        Returns:
        this to be able to use it fluently
      • getStream

        ReadStream<Buffer> getStream()
        Gets the data stream.
        Returns:
        the data stream
      • setStream

        MailAttachment setStream​(ReadStream<Buffer> stream)
        Sets the data stream.
        Parameters:
        stream - data stream to be used at attachment
        Returns:
        this to be able to use it fluently
      • getSize

        int getSize()
        Gets the size of the attachment.
        Returns:
        the size of the attachment
      • setSize

        MailAttachment setSize​(int size)
        Sets the size of the attachment.

        It is needed when using ReadStream for the MailAttachement.

        Parameters:
        size - the size of the attachment
        Returns:
        this to be able to use it fluently
      • getName

        String getName()
        get the name
        Returns:
        the name
      • setName

        MailAttachment setName​(String name)
        set the name
        Parameters:
        name - name of the attachment file
        Returns:
        this to be able to use it fluently

        name is the descriptive filename that will be put into the mail i.e. usually a local filename without path this can be set to "" to omit the filename attribute

      • getContentType

        String getContentType()
        get the Content-Type
        Returns:
        the contentType
      • setContentType

        MailAttachment setContentType​(String contentType)
        set the Content-Type
        Parameters:
        contentType - the contentType
        Returns:
        this to be able to use it fluently
      • getDisposition

        String getDisposition()
        get the disposition field
        Returns:
        the disposition
      • setDisposition

        MailAttachment setDisposition​(String disposition)
        set the disposition field to be used in the attachment
        Parameters:
        disposition - the disposition
        Returns:
        this to be able to use it fluently
      • getDescription

        String getDescription()
        get the description field
        Returns:
        the description
      • setDescription

        MailAttachment setDescription​(String description)
        set the description field to be used in the attachment
        Parameters:
        description - the description
        Returns:
        this to be able to use it fluently
      • getContentId

        String getContentId()
        get the Content-ID field
        Returns:
        the content id
      • setContentId

        MailAttachment setContentId​(String contentId)
        set the Content-ID field to be used in the attachment
        Parameters:
        contentId - the content id
        Returns:
        this to be able to use it fluently
      • addHeader

        MailAttachment addHeader​(String key,
                                 String value)
        Add an header to this attachment.
        Parameters:
        key - the header key
        value - the header value
        Returns:
        a reference to this, so the API can be used fluently
      • getHeaders

        MultiMap getHeaders()
        Get the headers to be added for this attachment.
        Returns:
        the headers
      • setHeaders

        MailAttachment setHeaders​(MultiMap headers)
        Set the headers to be added for this attachment.
        Parameters:
        headers - the headers to be added
        Returns:
        this to be able to use it fluently
      • toJson

        JsonObject toJson()
        convert this object to JSON representation
        Returns:
        the JSON object