Holger's
Java API

com.antelmann.net.mail
Class Email.Attachment

java.lang.Object
  extended by com.antelmann.net.mail.Email.Attachment
All Implemented Interfaces:
Serializable, DataSource
Enclosing class:
Email

public static class Email.Attachment
extends Object
implements Serializable, DataSource

Attachment represents an attachment to an email. Attachment requires the javax.activation package if the method getContentType() is called and the type has not been explicitly set before.

See Also:
Serialized Form

Constructor Summary
Email.Attachment(Email.Attachment a)
           
Email.Attachment(String fileName, byte[] content, String type)
           
 
Method Summary
 void addHeader(String name, String value)
          sets additional custom header
 byte[] getContent()
           
 String getContentID()
          returns the content ID that allows an HTML email to refer to this content for embedding (for example an image).
 String getContentType()
          if the content has not been explicitly set (or if the attachment was instanciated through a File object), this method call requires the javax.activation package.
 Email.Header[] getHeader()
          returns all headers
 Set<String> getHeaderNames()
          returns a set of String objects containing all header names
 String[] getHeaderValues(String name)
           
 InputStream getInputStream()
           
 String getName()
           
 OutputStream getOutputStream()
          always throws IOException; functionality not supported
 boolean isInline()
           
 boolean removeHeader(Email.Header h)
           
 MyFile saveToDir(File dir)
          the name of the attachment will be used as the file name; existing files would be overwritten
 void saveToFile(File file)
           
 void setContentID(String cid)
          surrounds the given cid with '<>' when adding it as header information; note that an attachment with a content ID is considered to be displayed inline in regards to the the Content-Disposition.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Email.Attachment

public Email.Attachment(Email.Attachment a)

Email.Attachment

public Email.Attachment(String fileName,
                        byte[] content,
                        String type)
Method Detail

getHeader

public Email.Header[] getHeader()
returns all headers


getHeaderNames

public Set<String> getHeaderNames()
returns a set of String objects containing all header names


getHeaderValues

public String[] getHeaderValues(String name)

addHeader

public void addHeader(String name,
                      String value)
sets additional custom header


removeHeader

public boolean removeHeader(Email.Header h)

getName

public String getName()
Specified by:
getName in interface DataSource

getContent

public byte[] getContent()

toString

public String toString()
Overrides:
toString in class Object

getContentID

public String getContentID()
returns the content ID that allows an HTML email to refer to this content for embedding (for example an image). For example, use
"<img src=\"cid:" + cid + "\" />"
in the body of the HTML message. The returned content ID does not entail the '<>' characters that are automatically placed when using setContentID(String).


setContentID

public void setContentID(String cid)
surrounds the given cid with '<>' when adding it as header information; note that an attachment with a content ID is considered to be displayed inline in regards to the the Content-Disposition.

See Also:
getContentID()

isInline

public boolean isInline()

getContentType

public String getContentType()
if the content has not been explicitly set (or if the attachment was instanciated through a File object), this method call requires the javax.activation package.

Specified by:
getContentType in interface DataSource

getOutputStream

public OutputStream getOutputStream()
                             throws IOException
always throws IOException; functionality not supported

Specified by:
getOutputStream in interface DataSource
Throws:
IOException

getInputStream

public InputStream getInputStream()
                           throws IOException
Specified by:
getInputStream in interface DataSource
Throws:
IOException

saveToDir

public MyFile saveToDir(File dir)
                 throws IOException
the name of the attachment will be used as the file name; existing files would be overwritten

Throws:
IOException

saveToFile

public void saveToFile(File file)
                throws IOException
Throws:
IOException


(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads