Holger's
Java API

com.antelmann.net.mail
Class Email

java.lang.Object
  extended by com.antelmann.net.mail.Email
All Implemented Interfaces:
Serializable

public class Email
extends Object
implements Serializable

Email represents an e-mail that could be sent through SMTP or received through POP3.

Since:
5/30/2002
Author:
Holger Antelmann
See Also:
EmailAccount, Serialized Form

Nested Class Summary
static class Email.Attachment
          Attachment represents an attachment to an email.
static class Email.Header
          A single Email may have several Header entries with the same name.
 
Field Summary
static String TEXT_HTML
           
static String TEXT_PLAIN
           
 
Constructor Summary
Email()
           
Email(Email email)
          constructs an Email object based on the parameters of the given one
 
Method Summary
 boolean addAttachment(Email.Attachment attachment)
           
 boolean addAttachment(File file)
           
 boolean addAttachment(String fileName, byte[] content, String type)
           
 void addHeader(String name, String value)
          sets additional custom header
 void addParameter(String key, String value)
          sets additional custom parameters (existing parameters are replaced)
 String asText()
          the return value could be used to be sent directly through a sendmail program
 Email.Attachment[] getAttachments()
          may return an empty array, but not null
 String getBCC()
           
 String getBody()
           
 String getCC()
           
 String getFrom()
           
 Email.Header[] getHeader()
          returns all headers
 Set<String> getHeaderNames()
          returns a set of String objects containing all header names
 String[] getHeaderValues(String name)
           
 Map<String,String> getParameters()
          returns additional custom parameters where String values are mapped to Sting values
 String getParameterValue(String key)
           
 String getSubject()
           
 String getTo()
           
 String getType()
          type is 'text/plain' by default
 boolean removeAttachment(Email.Attachment attachment)
           
 boolean removeHeader(Email.Header h)
           
 String removeParameter(String key)
           
 void setBCC(String bcc)
           
 void setBody(String message)
           
 void setCC(String cc)
           
 void setFrom(String from)
           
 void setSubject(String subject)
           
 void setTo(String to)
           
 void setType(String type)
           
static void validateAddressLine(String address)
          validates an address line that can contain one or more addresses.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TEXT_PLAIN

public static final String TEXT_PLAIN
See Also:
Constant Field Values

TEXT_HTML

public static final String TEXT_HTML
See Also:
Constant Field Values
Constructor Detail

Email

public Email(Email email)
constructs an Email object based on the parameters of the given one


Email

public Email()
Method Detail

getTo

public String getTo()

getFrom

public String getFrom()

getCC

public String getCC()

getBCC

public String getBCC()

getSubject

public String getSubject()

getBody

public String getBody()

getType

public String getType()
type is 'text/plain' by default


setTo

public void setTo(String to)

setFrom

public void setFrom(String from)

setCC

public void setCC(String cc)

setBCC

public void setBCC(String bcc)

setSubject

public void setSubject(String subject)

setBody

public void setBody(String message)

setType

public void setType(String type)

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)

getParameters

public Map<String,String> getParameters()
returns additional custom parameters where String values are mapped to Sting values


getParameterValue

public String getParameterValue(String key)

addParameter

public void addParameter(String key,
                         String value)
sets additional custom parameters (existing parameters are replaced)


removeParameter

public String removeParameter(String key)

addAttachment

public boolean addAttachment(File file)
                      throws IOException
Throws:
IOException

addAttachment

public boolean addAttachment(String fileName,
                             byte[] content,
                             String type)

addAttachment

public boolean addAttachment(Email.Attachment attachment)

getAttachments

public Email.Attachment[] getAttachments()
may return an empty array, but not null


removeAttachment

public boolean removeAttachment(Email.Attachment attachment)

asText

public String asText()
the return value could be used to be sent directly through a sendmail program


validateAddressLine

public static void validateAddressLine(String address)
                                throws javax.mail.internet.AddressException
validates an address line that can contain one or more addresses. Method uses javax.mail.internet package.

Throws:
javax.mail.internet.AddressException


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