![]() |
![]() |
||||
![]() |
|
||||
![]() |
|
CS Email Package : Programming Guide
This is a programming guide to the API of the CS Email Classes. This is basically a simplified version of what a JavaDoc would produce.
Use the links above to jump to the class descriptions.
Constructors | |
Address(String address) |
Constructs an Address object with an email address specified. ie, Address a = new Address( "jbloe@bloe.net" ); |
Address(String personal, String address) |
Constructs an Address object with the name and email address specified. ie, Address a = new Address( "Joe Bloe", "jbloe@bloe.net" ); |
Methods | |
String getAddress() |
Returns the email address. ie, will return "jbloe@bloe.net" (without quotes) |
String getPersonal() |
Returns the email name. ie, will return "Joe Bloe" (without quotes) |
void setAddress( String address ) |
This method sets the address field of an address object -- first, it checks the given string and makes sure that it's a valid email address. (ie, has an "@" symbol, etc). If it's not valid, an exception is thrown. This is done to ensure that email addresses being sent (via the transport class) are valid. You should notice that if the address is invalid, it does not get added. |
void setPersonal( String name ) |
Sets the personal email name (much like setAddress(...) sets the email address ). |
static Address[] parse(String addressList) |
The "parse()" method will parse a string of email address. When an
unresovable email address is encountered, it is skipped and the method
moves on to the next item in the list.
Use: Passing in "Bill,bill@place.com,Matt,matt@place.com" results in an array of two Address objects. (One has "Bill" and "bill@place.com" and the other has "Matt" and "matt@place.com".) Passing in "Bill,bill@place.com,matt@place.com" results in an array of two Address objects. (This is exactly similiar to the last example, only the second object only has "matt@place.com" stored -- NO email name.) Passing in "Bill,Bob,Ben,bill@place.com" results in an array with ONE Address object. It stores "Ben" as the name and "bill@place.com" as the email address. (It ignores the first 2 names because they're not associated with an email address, therefore not added.) |
Constructors | |
MalformedAddressException() |
Default constructor. |
MalformedAddressException(String msg) |
Do something with the "msg" parameter! It provides useful information
about each error.
For instance, the "msg" parameter can contain information about the malformed email -- I improved the error message strings in the Address class (see setPersonal() and setAddress()). Looking at those error strings should help you determine which email address or name is throwing an error. |
Constructors | |
Message() |
Default constructor. |
Methods | |
void addRecipient(int type, Address address) |
Adds one email address to the existing list of addresses. |
void addRecipients( int type, Address[] addresses ) |
Adds multiple email addresses to the existing list of addresses. |
void setReplyTo( Address replyToAddress ) |
Sets the Reply-To address. |
Address getReplyTo( ) |
Returns the Reply-To address. |
Address[] getRecipients( int type ) |
Returns the specified recipient array. |
Address[] getFrom( ) |
Returns the FROM address in an array of addresses. If no FROM address has been specified, the method returns null. |
String getSubject( ) |
Returns the message subject. |
String getText( ) |
Returns the message text. |
void setFrom( Address address ) |
Sets the FROM email address. (This will replace the current FROM address since there can be only one FROM address.) |
void setRecipient( int type, Address address ) |
This method will set one recipient and will override anything that has been previously stored. |
void setRecipients( int type, Address[] addresses ) |
This method will sets multiple recipients and will override anything that has been previously stored. |
void setSubject( String subject ) |
Sets the SUBJECT of the email. |
void setText( String msgText ) |
Sets the TEXT of the email. |
Fields | |
static final int TO |
Example usage: if( something == RecipientType.TO ) { ... } |
static final int CC |
Example usage: if( something == RecipientType.CC ) { ... } |
static final int BCC |
Example usage: if( something == RecipientType.BCC ) { ... } |
Constructors | |
Transport( String smtpHost, int smtpPort ) |
Construct a Transport object by specifying a host and port. |
Methods | |
String getSmtpHost( ) |
Returns the SMTP host (ie, smtpServer.coolservlets.com). |
int getSmtpPort( ) |
Returns the SMTP port number (usually 25). |
void setSmtpHost( String smtpHost ) |
Sets the SMTP host. |
void setSmtpPort( int smtpPort ) |
Sets the SMTP port number. |
void send( Message msg ) |
Sends the message by establishing a connection to the SMTP port. |
Interface Methods | |
void send ( Message msg ) |
|
String getSmtpHost ) |
|
int getSmtpPort( ) |
|
void setSmtpHost( String smtpHost ) |
|
void setSmtpPort( int smtpPort ) |
Constructors | |
TransportException() |
Default constructor. |
TransportException( String msg ) |
![]() |