com.jscape.inet.mime

## Class Attachment

- java.lang.Object
- - com.jscape.inet.mime.MimeMessage
  - - com.jscape.inet.mime.Attachment

- All Implemented Interfaces:
    java.io.Serializable

      public class Attachment
      extends MimeMessage

  Implements methods for creating an attachment to be added to a multi-part `MimeMessage`.

  Example Usage:

       Attachment att = new Attachment(new File("c:/tmp/image.gif"));

  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Attachment(byte[] data)` Constructs a new `Attachment` instance.
    `Attachment(java.io.File file)` Constructs a new `Attachment` instance.
    `Attachment(java.io.File file, java.lang.String characterEncoding)` Constructs a new `Attachment` instance.
    `Attachment(MimeMessage message)` Constructs a new `Attachment` instance from an existing MIME message.
    `Attachment(java.lang.String filename, byte[] data)` Constructs a new `Attachment` instance.
    `Attachment(java.lang.String filename, byte[] data, java.lang.String characterEncoding)` Constructs a new `Attachment` instance.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.String` | `getContentEncoding()` Gets Content-transfer-encoding header value for this `Attachment`.
    `java.lang.String` | `getContentType()` Gets content-type for this `Attachment`.
    `byte[]` | `getFileData()` Gets decoded content of this `Attachment`.
    `java.lang.String` | `getFilename()` Gets filename field contained in Content-Disposition header attribute for this `Attachment`.
    `void` | `setContentEncoding(java.lang.String ce)` Sets Content-Transfer-Encoding header for this `Attachment`.
    `void` | `setContentType(java.lang.String contentType)` Sets Content-Type header for this `Attachment`.

    - ### Methods inherited from class com.jscape.inet.mime.MimeMessage

      `addHeader, addHeader, addPart, addReplaceHeader, addReplaceHeader, getBody, getBodyAsFile, getBodyData, getBoundary, getContentTransferEncoding, getHeader, getHeaders, getHeaders, getHeaderValue, getMessage, getPart, getParts, getRawBodyData, removeHeader, removePart, removeParts, setBody, setBody, setBody, setBody, setBodyAsFile`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Attachment

          public Attachment(java.io.File file,
                            java.lang.String characterEncoding)
                     throws java.io.IOException,
                            MimeException

      Constructs a new `Attachment` instance.
      Parameters:
        `file` - the file to be attached
        `characterEncoding` - the character encoding of the attachment filename
      Throws:
        `java.io.IOException` - if an I/O error occurs
        `MimeException` - if a MIME related parsing error occurs

    - #### Attachment

          public Attachment(java.io.File file)
                     throws java.io.IOException,
                            MimeException

      Constructs a new `Attachment` instance.
      Parameters:
        `file` - the file to be attached
      Throws:
        `java.io.IOException` - if an I/O error occurs
        `MimeException` - if a MIME related parsing error occurs

    - #### Attachment

          public Attachment(java.lang.String filename,
                            byte[] data,
                            java.lang.String characterEncoding)
                     throws MimeException

      Constructs a new `Attachment` instance.
      Parameters:
        `filename` - the filename of the attachment
        `data` - the byte[] data for attachment
        `characterEncoding` - the character encoding used in the filename
      Throws:
        `MimeException` - if a MIME related parsing error occurs

    - #### Attachment

          public Attachment(java.lang.String filename,
                            byte[] data)
                     throws MimeException

      Constructs a new `Attachment` instance.
      Parameters:
        `filename` - the filename of the attachment
        `data` - the byte[] data for attachment
      Throws:
        `MimeException` - if a MIME related parsing error occurs

    - #### Attachment

          public Attachment(byte[] data)
                     throws MimeException

      Constructs a new `Attachment` instance.
      Parameters:
        `data` - the body byte[] data for attachment
      Throws:
        `MimeException` - if a MIME related error occurs

    - #### Attachment

          public Attachment(MimeMessage message)
                     throws MimeException

      Constructs a new `Attachment` instance from an existing MIME message.
      Parameters:
        `message` - the MimeMessage
      Throws:
        `MimeException` - if a MIME related error occurs

  - ### Method Detail

    - #### getContentType

          public java.lang.String getContentType()

      Gets content-type for this `Attachment`.
      Overrides:
        `getContentType` in class `MimeMessage`
      Returns:
        content-type

    - #### setContentType

          public void setContentType(java.lang.String contentType)
                              throws MimeException

      Sets Content-Type header for this `Attachment`.
      Overrides:
        `setContentType` in class `MimeMessage`
      Parameters:
        `contentType` - the content-type for this `Attachment`
      Throws:
        `MimeException` - if a MIME related error occurs

    - #### getContentEncoding

          public java.lang.String getContentEncoding()

      Gets Content-transfer-encoding header value for this `Attachment`.
      Returns:
        content-transfer-encoding or `null` if not found

    - #### setContentEncoding

          public void setContentEncoding(java.lang.String ce)
                                  throws MimeException

      Sets Content-Transfer-Encoding header for this `Attachment`.
      Parameters:
        `ce` - the content-transfer-encoding
      Throws:
        `MimeException` - if a MIME related error occurs

    - #### getFilename

          public java.lang.String getFilename()

      Gets filename field contained in Content-Disposition header attribute for this `Attachment`.
      Returns:
        filename

    - #### getFileData

          public byte[] getFileData()
                             throws java.lang.Exception

      Gets decoded content of this `Attachment`.
      Returns:
        the decoded content of this `Attachment`
      Throws:
        `java.lang.Exception` - if message could not be decoded

Copyright © JSCAPE LLC. 1999-2021. All Rights Reserved