|
SilverStream Application Server 3.5 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.sssw.srv.mail.AgoMailSend
Provides easy-to-use methods to construct and send RFC 822/MIME-compliant e-mail messages from the SilverStream Server.
Constructor Summary | |
AgoMailSend()
The constructor for the AgoMailSend class. |
Method Summary | |
void |
addBccAddress(String name,
String address)
Adds a Bcc: (blind carbon copy) address to the message being constructed. |
void |
addCcAddress(String name,
String address)
Adds a Cc: (carbon copy) address to the message being constructed. |
void |
addCcAddress(String name,
String address,
String charset)
Adds a Cc: (carbon copy) address to the message being constructed. |
void |
addFileAttachment(String filename)
Adds a file attachment to the message. |
void |
addHTMLTextPart(Reader reader)
Adds an HTML text part from a Reader. |
void |
addHTMLTextPart(Reader reader,
String charset,
String encoding)
Adds an HTML text part from a Reader. |
void |
addHTMLTextPart(String text)
Adds an HTML text part from a String. |
void |
addHTMLTextPart(String text,
String charset,
String encoding)
Adds an HTML text part from a String buffer. |
void |
addHTMLTextPartFromFile(String filename)
Adds an HTML text part from a file. |
void |
addHTMLTextPartFromFile(String filename,
String charset,
String encoding)
Adds an HTML text part from a file. |
void |
addPart(AgoMIMEPart part)
Add a part to this message. |
void |
addPlainTextPart(Reader reader)
Adds a plain text part from a Reader. |
void |
addPlainTextPart(Reader reader,
String charset,
String encoding)
Adds a plain text part from a Reader. |
void |
addPlainTextPart(String text)
Adds a plain text part from a String buffer. |
void |
addPlainTextPart(String text,
String charset,
String encoding)
Adds a plain text part from a String buffer. |
void |
addPlainTextPartFromFile(String filename)
Adds a plain text part from a file. |
void |
addPlainTextPartFromFile(String filename,
String charset,
String encoding)
Adds a plain text part from a file. |
void |
addToAddress(String name,
String address)
Adds a To: (primary) address to the message being constructed. |
void |
addToAddress(String name,
String address,
String charset)
Adds a To: (primary) address to the message being constructed. |
void |
removeBccAddresses()
Removes all the Bcc: addresses from the message. |
void |
removeCcAddresses()
Removes all the Cc: addresses from the message. |
void |
removeToAddresses()
Removes all the To: addresses from the message. |
void |
setFrom(String name,
String address)
Sets the From: address that appears on the message. |
void |
setFrom(String name,
String address,
String charset)
Sets the From: address that appears on the message. |
void |
setOrganization(String organization)
Sets the name of the organization that appears on the message. |
void |
setOrganization(String organization,
String charset)
Sets the name of the organization that appears on the message. |
void |
setReplyTo(String name,
String address)
Sets the Reply to: address that appears on the message. |
void |
setReplyTo(String name,
String address,
String charset)
Sets the Reply to: address that appears on the message. |
void |
setSubject(String subject)
Sets the Subject that appears on the message. |
void |
setSubject(String subject,
String charset)
Sets the Subject that appears on the message. |
String |
submitMessage(String server)
Submits the message to the specified SMTP server. |
String |
submitMessage(String server,
String domain)
Submit the message to the specified from the specified domain. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public AgoMailSend()
The following code fragment illustrates how to create a new message by instantiating the AgoMailSend class.
AgoMailSend msg = new AgoMailSend(); msg.setFrom("Bob Jones", "jones@company.com"); msg.addToAddress("Chris Smith", "smith@company.com"); msg.setSubject("Hi There"); msg.setOrganization("XYZ Corp"); msg.addPlainTextPart("Hello World!"); msg.submitMessage("mail.company.com");
Method Detail |
public void setFrom(String name, String address) throws AgoMailSendException
name
- a name to be associated with the From: address (e.g. Chris Smith). Optional.address
- the From: address (e.g. smith@company.com).The setFrom() method overwrites the current From address.
The following code fragment illustrates how to set the From address of a message.
msg.setFrom("Chris Smith", "smith@company.com");
public void setFrom(String name, String address, String charset) throws AgoMailSendException
name
- a name to be associated with the From: address (e.g. Chris Smith). Optional.address
- the From: address (e.g. smith@company.com).charset
- the character set of the Name.The setFrom() method overwrites the current From address.
public void setOrganization(String organization) throws AgoMailSendException
organization
- the name of the organization.
The setOrganization()
method overwrites the current Organization.
msg.setOrganization("XYZ Corp");
public void setOrganization(String organization, String charset) throws AgoMailSendException
organization
- the name of the organization.charset
- the character set of the Name.
The setOrganization()
method overwrites the current Organization.
msg.setOrganization("XYZ Corp");
public void setReplyTo(String name, String address) throws AgoMailSendException
name
- a name to be associated with the Reply to:
address. (e.g. Chris Smith). Optional.address
- the Reply to: address. (e.g. smith@company.com).
The setReplyTo()
method overwrites the current Reply To
address. If a message does not have a reply to address most mail programs
will use the From field as described in RFC 822. As such, in common
usage a reply to field is often unnecessary.
The following code fragment illustrates how to set a Reply To address.
msg.setReplyTo("Chris Smith", "smith@company.com");
public void setReplyTo(String name, String address, String charset) throws AgoMailSendException
name
- a name to be associated with the Reply to:
address. (e.g. Chris Smith). Optional.address
- the Reply to: address. (e.g. smith@company.com).charset
- the character set of the Name.
The setReplyTo()
method overwrites the current Reply To
address. If a message does not have a reply to address most mail programs
will use the From field as described in RFC 822. As such, in common
usage a reply to field is often unnecessary.
public void setSubject(String subject)
subject
- the message subject.
The setSubject()
method overwrites the current Subject.
The following code fragment illustrates how to set the Subject of a message.
msg.setSubject("Meeting minutes");
public void setSubject(String subject, String charset)
subject
- the message subject.charset
- the character set of the Name.
The setSubject()
method overwrites the current Subject.
public void addToAddress(String name, String address) throws AgoMailSendException
name
- a name to be associated with the To: address. (e.g. Chris Smith). Optional.address
- the To: address (e.g. smith@company.com).The following code fragment illustrates how to add a To: address to a message.
msg.addToAddress("Chris Smith", "smith@company.com");
public void addToAddress(String name, String address, String charset) throws AgoMailSendException
name
- a name to be associated with the To: address. (e.g. Chris Smith). Optional.address
- the To: address (e.g. smith@company.com).charset
- the character set for the name.public void addCcAddress(String name, String address) throws AgoMailSendException
name
- a name to be associated with the Cc: address. (e.g. Chris Smith). Optional.address
- the Cc: address (e.g. smith@company.com).The following code fragment illustrates how to add a Cc address to a message.
msg.addCcAddress("Chris Smith","smith@company.com");
public void addCcAddress(String name, String address, String charset) throws AgoMailSendException
name
- a name to be associated with the Cc: address. (e.g. Chris Smith). Optional.address
- the Cc: address (e.g. smith@company.com).charset
- the character set for the name.public void addBccAddress(String name, String address) throws AgoMailSendException
name
- a name to be associated with the Bcc: address. (e.g. Chris Smith). Optional.address
- the Bcc: address (e.g. smith@company.com).The following code fragment illustrates how to add a Bcc address to a message.
msg.addBccAddress("Chris Smith", "smith@company.com");
public void removeToAddresses()
msg.removeToAddresses();
public void removeCcAddresses()
msg.removeCcAddresses();
public void removeBccAddresses()
msg.removeBccAddresses();
public void addPlainTextPart(String text) throws AgoMailSendException
text
- a String buffer that contains the text for the part.This version of the addPlainTextPart() method assumes the text is 7- bit US-ASCII. If the text is not 7-bit US-ASCII, use the three argument version of this method and specify the character set and desired encoding mechanism.
The following code fragment illustrates how to add a plain text part to a message.
msg.addPlainTextPart("Hello World!");
public void addPlainTextPart(String text, String charset, String encoding) throws AgoMailSendException
text
- a String buffer that contains the text for the part.charset
- the character set of the text
(e.g. iso-8859-1). See AgoMIME
for a
list of supported character sets.encoding
- the encoding mechanism to use
(e.g. quoted-printable). See AgoMIME
for a
list of supported encoding mechanisms.
Note that the addPlainTextPart()
method is overloaded. Use
this version to specify the character set and desired
encoding mechanism.
public void addPlainTextPart(Reader reader) throws AgoMailSendException
reader
- the Reader that contains the text for the part.
This version of the addPlainTextPart()
method assumes the
text is 7- bit US-ASCII. If the text is not 7-bit US-ASCII, use the
three argument version of this method and specify the character set and
desired encoding mechanism.
FileReader r = new FileReader(defaultFileReader); msg.addPlainTextPart(r);
public void addPlainTextPart(Reader reader, String charset, String encoding) throws AgoMailSendException
reader
- the Reader that contains the text for the part.charset
- the character set of the text
(e.g. iso-8859-1). See AgoMIME
for a
list of supported character sets.encoding
- the encoding mechanism to use
(e.g. quoted-printable). See AgoMIME
for a
list of supported encoding mechanisms.
Note that the addPlainTextPart()
method is overloaded. Use
this version to add a plain text part from a Reader and
specify the character set and desired encoding mechanism for the text.
public void addPlainTextPartFromFile(String filename) throws AgoMailSendException
filename
- the name of the file that contains the text for the part.
This version of the addPlainTextPartFromFile()
method
assumes the text is 7- bit US-ASCII. If the text is not 7-bit US-ASCII,
use the three argument version of this method and specify the character
set and desired encoding mechanism.
msg.addPlainTextPartFromFile("c:\\someDirectory\\someFile.txt");
public void addPlainTextPartFromFile(String filename, String charset, String encoding) throws AgoMailSendException
filename
- the name of the file that contains the text for the part.charset
- the character set of the text
(e.g. iso-8859-1). See AgoMIME
for a
list of supported character sets.encoding
- the encoding mechanism to use
(e.g. quoted-printable). See AgoMIME
for a
list of supported encoding mechanisms.
Note that the addPlainTextPartFromFile()
method is
overloaded. Use this version to specify the character set
and desired encoding mechanism.
public void addHTMLTextPart(String text) throws AgoMailSendException
text
- the name of the file that contains the HTML text for the part.
This version of the addHTMLTextPart()
method assumes the
text is 7- bit US-ASCII. If the text is not 7-bit US-ASCII, use the
three argument version of this method and specify the character set and
desired encoding mechanism.
The following code fragment illustrates how to add an HTML text part to a message.
msg.addHTMLTextPart("<HTML><P>Hello World!</HTML>");
public void addHTMLTextPart(String text, String charset, String encoding) throws AgoMailSendException
text
- a String buffer that contains the HTML text for the part.charset
- the character set of the text
(e.g. iso-8859-1). See AgoMIME
for a
list of supported character sets.encoding
- the encoding mechanism to use
(e.g. quoted-printable). See AgoMIME
for a
list of supported encoding mechanisms.
Note that the addHTMLTextPart()
method is overloaded. Use
this version to specify the character set and the encoding
mechanism.
The following code fragment illustrates how to add an HTML text part:
msg.addHTMLTextPart("<HTML><P>Hello World!</HTML>", AgoMIME.CHARSET_ISO_8859_1, AgoMIME.MECHANISM_QUOTED_PRINTABLE);
public void addHTMLTextPart(Reader reader) throws AgoMailSendException
reader
- a Reader that contains the HTML text for the part.
This version of the addHTMLTextPart()
method assumes the
text is 7- bit US-ASCII. If the text is not 7-bit US-ASCII, use the
three argument version of this method and specify the character set and
desired encoding mechanism.
The following code fragment illustrates how to add an HTML text part:
FileReader r=new FileReader(defaultReaderFile); msg.addHTMLTextPart(r);
public void addHTMLTextPart(Reader reader, String charset, String encoding) throws AgoMailSendException
reader
- a Reader that contains the HTML text for the part.charset
- the character set of the text
(e.g. iso-8859-1). See AgoMIME
for a
list of supported character sets.encoding
- the encoding mechanism to use
(e.g. quoted-printable). See AgoMIME
for a
list of supported encoding mechanisms.
Note that the addHTMLTextPart()
method is overloaded.
Use this version to add an HTML text part from a Reader and specify the character set and desired encoding mechanism.
public void addHTMLTextPartFromFile(String filename) throws AgoMailSendException
filename
- the name of the file that contains the HTML text for the part.
This version of the addHTMLTextPartFromFile()
method
assumes the text is 7- bit US-ASCII. If the text is not 7-bit US-ASCII,
use the three argument version of this method and specify the character
set and desired encoding mechanism.
msg.addHTMLTextPartFromFile("someFile.txt");
public void addHTMLTextPartFromFile(String filename, String charset, String encoding) throws AgoMailSendException
filename
- the name of the file that contains the HTML text for the part.charset
- the character set of the text
(e.g. iso-8859-1). See AgoMIME
for a
list of supported character sets.encoding
- the encoding mechanism to use
(e.g. quoted-printable). See AgoMIME
for a
list of supported encoding mechanisms.
Note that the addHTMLTextPartFromFile()
method is
overloaded. Use this version to specify the character set
and desired encoding mechanism.
public void addFileAttachment(String filename) throws AgoMailSendException
filename
- the name of the file to be attached.A file attachment is always added as a new MIME part of Content-Type application/octet-stream. If there is more than one part, the message automatically becomes a multipart message.
The following code fragment illustrates how to add a file attachment to a message.
msg.addFileAttachment("temp\foo.exe");
AgoMailSend.addPlainTextPartFromFile(java.lang.String)
public String submitMessage(String server) throws AgoMailSendException
server
- the name of the server.The following code fragment shows how to submit a message to the mail.company.com SMTP server.
msg.submitMessage("mail.company.com");
public String submitMessage(String server, String domain) throws AgoMailSendException
server
- The name of the SMTP server to use to send the maildomain
- The domain name of the server (e.g. silverstream.com)Some mailers check the domain of the sender. Note that this check does not provide genuine security.
public void addPart(AgoMIMEPart part)
part
- the new part for this message.If the part you add is the first part, it becomes the message part. If another part is added, this will become the first part of a multipart message.
Note that adding a part does not add headers to a message. Headers (To, Subject, CC, etc.) must be added using the other methods in this class.
AgoMailSend.setFrom( String name, String address )
,
AgoMailSend.setOrganization( String organization )
,
AgoMailSend.setReplyTo( String name, String address )
,
AgoMailSend.setSubject( String subject )
,
AgoMailSend.addToAddress( String name, String address )
,
AgoMailSend.addCcAddress( String name, String address )
|
SilverStream Application Server 3.5 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |