Class Attachment

java.lang.Object
com.independentsoft.msg.Attachment

public class Attachment extends Object
Represents an attachment to a message.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Initializes a new instance of the Attachment class.
    Attachment​(String filePath)
    Initializes a new instance of the Attachment class based on the supplied file.
    Attachment​(String fileName, byte[] buffer)
    Initializes a new instance of the Attachment class based on the supplied byte array.
    Attachment​(String fileName, InputStream inputStream)
    Instantiates a new attachment.
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    Gets file type information for a non-Windows attachment.
    Gets the content base header of a MIME message attachment.
    Gets the content disposition header of a MIME message attachment.
    Gets the content identification header of a MIME message attachment.
    Gets the content location header of a MIME message attachment.
    byte[]
    Gets binary attachment data.
    byte[]
    Gets attachment's data as embedded object.
    Gets the display name of the attachment.
    Gets Message object if the attachment is an embedded Message.
    byte[]
    Gets the encoding for an attachment.
    Gets a file name extension that indicates the document type of an attachment.
    Gets an attachment's base file name and extension, excluding path.
    Gets flags for an attachment.
    Gets stream to read from this attachment.
    Gets an attachment's long filename and extension, excluding path.
    Gets an attachment's fully-qualified long path and filename.
    Gets a MAPI-defined constant representing the way the contents of an attachment can be accessed.
    long
    Gets the MIME sequence number of a MIME message attachment.
    Gets formatting information about a MIME attachment.
    Gets the type of the attachment.
    Gets an attachment's fully-qualified path and filename.
    byte[]
    Gets the record key for an attachment.
    byte[]
    Gets a metafile with rendering information for an attachment.
    long
    Gets rendering position index.
    long
    Gets attachment's size in bytes.
    byte[]
    Gets an object identifier specifying the application that supplied an attachment.
    Gets the name of an attachment file modified so that it can be associated with TNEF messages.
    boolean
    Gets whether this attachment is a contact photo.
    boolean
    Gets whether an attachment is hidden from the end user.
    void
    save​(OutputStream outputStream)
    Saves this attachment to the specified stream.
    void
    save​(String filePath)
    Saves this attachment to the specified file.
    void
    save​(String filePath, boolean overwrite)
    Saves this attachment to the specified file.
    void
    setAdditionalInfo​(byte[] additionalInfo)
    Provides file type information for a non-Windows attachment.
    void
    setContactPhoto​(boolean isContactPhoto)
    Sets whether this attachment is a contact photo.
    void
    setContentBase​(String contentBase)
    Sets the content base header of a MIME message attachment.
    void
    setContentDisposition​(String contentDisposition)
    Sets the content disposition header of a MIME message attachment.
    void
    setContentId​(String contentId)
    Sets the content identification header of a MIME message attachment.
    void
    setContentLocation​(String contentLocation)
    Sets the content location header of a MIME message attachment.
    void
    setData​(byte[] data)
    Sets binary attachment data.
    void
    setDataObject​(byte[] dataObject)
    Sets attachment's data as embedded object.
    void
    setDisplayName​(String displayName)
    Sets the display name of the attachment.
    void
    setEmbeddedMessage​(Message embeddedMessage)
    Sets Message object if the attachment is an embedded Message.
    void
    setEncoding​(byte[] encoding)
    Sets the encoding for an attachment.
    void
    setExtension​(String extension)
    Sets a file name extension that indicates the document type of an attachment.
    void
    setFileName​(String fileName)
    Sets an attachment's base file name and extension, excluding path.
    void
    Sets flags for an attachment.
    void
    setHidden​(boolean isHidden)
    Sets whether an attachment is hidden from the end user.
    void
    setLongFileName​(String longFileName)
    Sets an attachment's long filename and extension, excluding path.
    void
    setLongPathName​(String longPathName)
    Sets an attachment's fully-qualified long path and filename.
    void
    Sets a MAPI-defined constant representing the way the contents of an attachment can be accessed.
    void
    setMimeSequence​(long mimeSequence)
    Sets the MIME sequence number of a MIME message attachment.
    void
    setMimeTag​(String mimeTag)
    Sets formatting information about a MIME attachment.
    void
    setObjectType​(ObjectType objectType)
    Sets the type of the attachment.
    void
    setPathName​(String pathName)
    Sets an attachment's fully-qualified path and filename.
    void
    setRecordKey​(byte[] recordKey)
    Sets the record key for an attachment.
    void
    setRendering​(byte[] rendering)
    Sets a metafile with rendering information for an attachment.
    void
    setRenderingPosition​(long renderingPosition)
    Sets rendering position index.
    void
    setSize​(long size)
    Sets attachment's size in bytes.
    void
    setTag​(byte[] tag)
    Sets an object identifier specifying the application that supplied an attachment.
    void
    setTransportName​(String transportName)
    Sets the name of an attachment file modified so that it can be associated with TNEF messages.
    byte[]
    Gets bytes to read from this attachment.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Attachment

      public Attachment()
      Initializes a new instance of the Attachment class.
    • Attachment

      public Attachment(String filePath) throws IOException
      Initializes a new instance of the Attachment class based on the supplied file.
      Parameters:
      filePath - the file path
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • Attachment

      public Attachment(String fileName, InputStream inputStream) throws IOException
      Instantiates a new attachment.
      Parameters:
      fileName - the file name
      inputStream - the input stream
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • Attachment

      public Attachment(String fileName, byte[] buffer)
      Initializes a new instance of the Attachment class based on the supplied byte array.
      Parameters:
      fileName - Attachment file name.
      buffer - A byte array.
  • Method Details

    • save

      public void save(String filePath) throws IOException
      Saves this attachment to the specified file.
      Parameters:
      filePath - File path.
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • save

      public void save(String filePath, boolean overwrite) throws IOException
      Saves this attachment to the specified file.
      Parameters:
      filePath - File path.
      overwrite - True to overwrite existing file, otherwise false.
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • save

      public void save(OutputStream outputStream) throws IOException
      Saves this attachment to the specified stream.
      Parameters:
      outputStream - A stream.
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • toByteArray

      public byte[] toByteArray()
      Gets bytes to read from this attachment.
      Returns:
      Attachment as a byte array.
    • getInputStream

      public InputStream getInputStream()
      Gets stream to read from this attachment.
      Returns:
      A stream.
    • getAdditionalInfo

      public byte[] getAdditionalInfo()
      Gets file type information for a non-Windows attachment.
      Returns:
      the additional info
    • setAdditionalInfo

      public void setAdditionalInfo(byte[] additionalInfo)
      Provides file type information for a non-Windows attachment.
      Parameters:
      additionalInfo - the new additional info
    • getContentBase

      public String getContentBase()
      Gets the content base header of a MIME message attachment.
      Returns:
      the content base
    • setContentBase

      public void setContentBase(String contentBase)
      Sets the content base header of a MIME message attachment.
      Parameters:
      contentBase - the new content base
    • getContentId

      public String getContentId()
      Gets the content identification header of a MIME message attachment.
      Returns:
      the content id
    • setContentId

      public void setContentId(String contentId)
      Sets the content identification header of a MIME message attachment.
      Parameters:
      contentId - the new content id
    • getContentLocation

      public String getContentLocation()
      Gets the content location header of a MIME message attachment.
      Returns:
      the content location
    • setContentLocation

      public void setContentLocation(String contentLocation)
      Sets the content location header of a MIME message attachment.
      Parameters:
      contentLocation - the new content location
    • getContentDisposition

      public String getContentDisposition()
      Gets the content disposition header of a MIME message attachment.
      Returns:
      the content disposition
    • setContentDisposition

      public void setContentDisposition(String contentDisposition)
      Sets the content disposition header of a MIME message attachment.
      Parameters:
      contentDisposition - the new content disposition
    • getData

      public byte[] getData()
      Gets binary attachment data.
      Returns:
      the data
    • setData

      public void setData(byte[] data)
      Sets binary attachment data.
      Parameters:
      data - the new data
    • getDataObject

      public byte[] getDataObject()
      Gets attachment's data as embedded object.
      Returns:
      the data object
    • setDataObject

      public void setDataObject(byte[] dataObject)
      Sets attachment's data as embedded object.
      Parameters:
      dataObject - the new data object
    • getEncoding

      public byte[] getEncoding()
      Gets the encoding for an attachment.
      Returns:
      the encoding
    • setEncoding

      public void setEncoding(byte[] encoding)
      Sets the encoding for an attachment.
      Parameters:
      encoding - the new encoding
    • getRecordKey

      public byte[] getRecordKey()
      Gets the record key for an attachment.
      Returns:
      the record key
    • setRecordKey

      public void setRecordKey(byte[] recordKey)
      Sets the record key for an attachment.
      Parameters:
      recordKey - the new record key
    • getExtension

      public String getExtension()
      Gets a file name extension that indicates the document type of an attachment.
      Returns:
      the extension
    • setExtension

      public void setExtension(String extension)
      Sets a file name extension that indicates the document type of an attachment.
      Parameters:
      extension - the new extension
    • getFileName

      public String getFileName()
      Gets an attachment's base file name and extension, excluding path.
      Returns:
      the file name
    • setFileName

      public void setFileName(String fileName)
      Sets an attachment's base file name and extension, excluding path.
      Parameters:
      fileName - the new file name
    • getFlags

      public AttachmentFlags getFlags()
      Gets flags for an attachment.
      Returns:
      the flags
    • setFlags

      public void setFlags(AttachmentFlags flags)
      Sets flags for an attachment.
      Parameters:
      flags - the new flags
    • getLongFileName

      public String getLongFileName()
      Gets an attachment's long filename and extension, excluding path.
      Returns:
      the long file name
    • setLongFileName

      public void setLongFileName(String longFileName)
      Sets an attachment's long filename and extension, excluding path.
      Parameters:
      longFileName - the new long file name
    • getLongPathName

      public String getLongPathName()
      Gets an attachment's fully-qualified long path and filename.
      Returns:
      the long path name
    • setLongPathName

      public void setLongPathName(String longPathName)
      Sets an attachment's fully-qualified long path and filename.
      Parameters:
      longPathName - the new long path name
    • getMethod

      public AttachmentMethod getMethod()
      Gets a MAPI-defined constant representing the way the contents of an attachment can be accessed.
      Returns:
      the method
    • setMethod

      public void setMethod(AttachmentMethod method)
      Sets a MAPI-defined constant representing the way the contents of an attachment can be accessed.
      Parameters:
      method - the new method
    • getMimeSequence

      public long getMimeSequence()
      Gets the MIME sequence number of a MIME message attachment.
      Returns:
      the mime sequence
    • setMimeSequence

      public void setMimeSequence(long mimeSequence)
      Sets the MIME sequence number of a MIME message attachment.
      Parameters:
      mimeSequence - the new mime sequence
    • getMimeTag

      public String getMimeTag()
      Gets formatting information about a MIME attachment.
      Returns:
      the mime tag
    • setMimeTag

      public void setMimeTag(String mimeTag)
      Sets formatting information about a MIME attachment.
      Parameters:
      mimeTag - the new mime tag
    • getPathName

      public String getPathName()
      Gets an attachment's fully-qualified path and filename.
      Returns:
      the path name
    • setPathName

      public void setPathName(String pathName)
      Sets an attachment's fully-qualified path and filename.
      Parameters:
      pathName - the new path name
    • getRendering

      public byte[] getRendering()
      Gets a metafile with rendering information for an attachment.
      Returns:
      the rendering
    • setRendering

      public void setRendering(byte[] rendering)
      Sets a metafile with rendering information for an attachment.
      Parameters:
      rendering - the new rendering
    • getRenderingPosition

      public long getRenderingPosition()
      Gets rendering position index.
      Returns:
      the rendering position
    • setRenderingPosition

      public void setRenderingPosition(long renderingPosition)
      Sets rendering position index.
      Parameters:
      renderingPosition - the new rendering position
    • getSize

      public long getSize()
      Gets attachment's size in bytes.
      Returns:
      the size
    • setSize

      public void setSize(long size)
      Sets attachment's size in bytes.
      Parameters:
      size - the new size
    • getTag

      public byte[] getTag()
      Gets an object identifier specifying the application that supplied an attachment.
      Returns:
      the tag
    • setTag

      public void setTag(byte[] tag)
      Sets an object identifier specifying the application that supplied an attachment.
      Parameters:
      tag - the new tag
    • getTransportName

      public String getTransportName()
      Gets the name of an attachment file modified so that it can be associated with TNEF messages.
      Returns:
      the transport name
    • setTransportName

      public void setTransportName(String transportName)
      Sets the name of an attachment file modified so that it can be associated with TNEF messages.
      Parameters:
      transportName - the new transport name
    • getDisplayName

      public String getDisplayName()
      Gets the display name of the attachment.
      Returns:
      the display name
    • setDisplayName

      public void setDisplayName(String displayName)
      Sets the display name of the attachment.
      Parameters:
      displayName - the new display name
    • getEmbeddedMessage

      public Message getEmbeddedMessage()
      Gets Message object if the attachment is an embedded Message.
      Returns:
      the embedded message
    • setEmbeddedMessage

      public void setEmbeddedMessage(Message embeddedMessage)
      Sets Message object if the attachment is an embedded Message.
      Parameters:
      embeddedMessage - the new embedded message
    • getObjectType

      public ObjectType getObjectType()
      Gets the type of the attachment.
      Returns:
      the object type
    • setObjectType

      public void setObjectType(ObjectType objectType)
      Sets the type of the attachment.
      Parameters:
      objectType - the new object type
    • isHidden

      public boolean isHidden()
      Gets whether an attachment is hidden from the end user.
      Returns:
      true, if is hidden
    • setHidden

      public void setHidden(boolean isHidden)
      Sets whether an attachment is hidden from the end user.
      Parameters:
      isHidden - the new hidden
    • isContactPhoto

      public boolean isContactPhoto()
      Gets whether this attachment is a contact photo.
      Returns:
      true, if is contact photo
    • setContactPhoto

      public void setContactPhoto(boolean isContactPhoto)
      Sets whether this attachment is a contact photo.
      Parameters:
      isContactPhoto - the new contact photo