include("../../template.php"); global $right_image, $left_image, $section_title; $right_image="bricks.jpg"; $left_image="rainbow-bricks.jpg"; $section_title="Gay-Lesbian-Bisexual-Transgendered";start_top(); ?> w3c//dtd html 4.0 transitional//en">
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--cylikon.MailerBean.Mailer
cylikon.MailerBean.Mailer
mail=new cylikon.MailerBean.Mailer();
// set the TO field
mail.addTO("myFriend@myhost.com");
// set the FROM field
mail.setFROM("me@someplace.com")
mail.addCC("myOtherFriend@myhost.com");
mail.addBCC("PrivateInvestigator@secrethost.com");
mail.setSubject("Hi
Friend!");
mail.setMessage("Just
wanted to say Hi, and see how you were doing....");
//Now, let's get status
string which will tell us if the mail has been sent..
// call the ConstructAndSend(boolean
ConstructOnly_NoSend) method and
// set ConstructOnly_NoSend
= FALSE, because we DO want the message sent
String status=mail.ConstructAndSend(false);
System.out.println(status);
// If you don't to
create the string "status" you could just call the method,
// ConstructAndSend(false),
then check the boolean to see if it was sent...
boolean mailCheck=mail.MailSent();
if (mailCheck) {System.out.print("Mail
was sent");} else {System.out.print("Sending failed");}
SEE THE MailerBeanExample.txt
file for hints on using more advanced features.
Constructor Summary | |
Mailer() |
Method Summary | |
void | addAttachment(java.io.File
data_to_be_attached, java.lang.String mimetype, java.lang.String file_name,
java.lang.String file_description)
Add attachments by providing a File, mime type, file name, and short description. Example:
This method should be VERY
convienient for use in GUIs which will be using a JFileChooser to add attachments.
In addition, using URLs for attachments should be quite easy as well, since
the developer do the following:
|
void | addBCC(java.lang.String
new_BCC)
Adds individual Blind Carbon
Copy addresses to the MimeMessage.
|
void | addCC(java.lang.String
new_CC)
Adds individual Carbon Copy
addresses to the MimeMessage.
|
void | addTO(java.lang.String
new_TO)
Adds individual TO addresses
to the MimeMessage.
|
void | ClearOldMessage()
Invoke this method after a message has been sent, or otherwise no longer needed. This method releases all resources no longer in use, and creates a clean slate for sending the next MimeMessage. This method removes all attachments, all addresses, clears all messages and headers, and creates a fresh new Session and MimeMessage. This method is automatically invoked if a message is successfully sent. |
java.lang.String | ConstructAndSend(boolean
ConstructOnly_NoSend)
This method is responsible for, at a minimum, constructing the MimeMessage to be sent, and should be called after *all* other methods affecting this message have been called. All necessary Set and Add methods need to be called prior to attempting to send. The ConstructOnly_NoSend boolean allows this method to operate in one of two modes. IMPORTANT:
If ConstructOnly_NoSend is set to TRUE, the message will NOT be sent. Instead, it will be constructed WITHOUT sending. This would allow you to make a call to getRawMimeMessage(). NOTE: This is the *only* instance in which getRawMimeMessage() should be called. This method returns a string, which , if read, will be determined by either the getMailSuccessMessage, or any one of the "warning" methods, suchs as getNoFROMWarning(), or getBadTOWarning. It is up to use to make use of the appropriate Set methods to adapt these messages to your liking. If you simply want a basic "yes" or "no" answer as to whether sending succeeded, invoke the MailSent() method, which returns a boolean. |
java.lang.String | getAddressException()
Returns the the message to be shown in the event a javax.mail.internet.AddressException occurs with one or more addresses. |
java.lang.String | getBadBCCWarning()
Gets the message to be shown the client if an invalid BCC address has been provided, and an attempt was made to send the mail. If this error occurs, the ConstructAndSend() method will return THIS string instead of a success message.This method helps avoid unnecessary AddressExceptions and provides the client with a specific explanation for why his/her email was rejected. |
java.lang.String | getBadCCWarning()
Gets the message to be shown the client if an invalid CC address has been provided, and an attempt was made to send the mail. If this error occurs, the ConstructAndSend() method will return THIS string instead of a success message.This method helps avoid unnecessary AddressExceptions and provides the client with a specific explanation for why his/her email was rejected. |
java.lang.String | getBadFROMWarning()
Gets the message to be shown the client if an invalid FROM address has been provided, and an attempt was made to send the mail. If this error occurs, the ConstructAndSend() method will return THIS string instead of a success message.This method helps avoid unnecessary AddressExceptions and provides the client with a specific explanation for why his/her email was rejected. |
java.lang.String | getBadTOWarning()
Gets the message to be shown the client if an invalid TO address has been provided, and an attempt was made to send the mail. If this error occurs, the ConstructAndSend() method will return THIS string instead of a success message.This method helps avoid unnecessary AddressExceptions and provides the client with a specific explanation for why his/her email was rejected. |
java.util.Vector | getBcc()
Returns a Vector of all BCC addresses currently associated with this MimeMessage. The method will return an empty Vector (not a null), if no address have yet been set. |
java.util.Vector | getCc()
Returns a Vector of all CC addresses currently associated with this MimeMessage. The method will return an empty Vector (not a null), if no address have yet been set. |
java.lang.String | getDefaultMimeType()
Returns the default message ime type currently asoociated with this message. CHANGING THE MIME-TYPE (for
HTML Mail etc.):
The 4 supported formats are: text/plain, text/html, multipart/mixed, message/rfc822 Please note, that as of this writing, only JavaMail version 1.1.3 and above supports text/html. |
java.lang.String | getExtraHeaderLine()
Returns any extra mail header line you have added to the current message. NOTE: Not all mail clients show message headers. |
java.lang.String | getFrom()
Returns the FROM address for the current MimeMessage, or null if the value has not been set. |
boolean | getGreenLight()
Not implimented. |
java.lang.String | getMailSuccessMessage()
Returns the text message to be shown the client upon successful sending of a message. |
java.lang.String | getMessage()
Gets the text message to be included in the current MimeMessage, or null if no message has been set. |
java.lang.String | getMessageException()
Gets the message to be displayed to the client in the event a javax.mail.MessagingException occurs. |
javax.mail.Session | getMessageSession()
Returns the Session object used to construct the current MimeMessage. |
java.lang.String | getMSMailPriority()
Returns the mail priority
understood by most Microsoft mail clients.
String pr = mail.getMSMailPriority(); |
java.lang.String | getNetscapeMailPriority()
Returns the mail priority
understood by most Netscape mail clients.
String pr = mail.getNetscapeMailPriority(); |
java.lang.String | getNoFROMWarning()
Gets the message to be shown the client if no FROM address has been provided, but an attempt was made to send the mail. If this error occurs, the ConstructAndSend() method will return THIS string instead of a success message. |
java.lang.String | getNoMessageWarning()
Gets the message to be shown the client if no message body has been provided, but an attempt was made to send the mail. If this error occurs, the ConstructAndSend() method will return THIS string instead of a success message. |
java.lang.String | getNoTOWarning()
Gets the message to be shown the client if no TO address has been provided, but an attempt was made to send the mail. If this error occurs, the ConstructAndSend() method will return THIS string instead of a success message. |
javax.mail.internet.MimeMessage | getRawMimeMessage()
This method should only be
called after ConstructAndSend(true) has been called.
|
java.lang.String | getSenderInfo()
Returns any extra sender information you have chosen to attach to the bottom of the current message. |
java.util.Properties | getSessionProperties()
Returns the Properties object used to construct the Session for the current MimeMessage. |
java.lang.String | getSMTP_Host()
Returns the SMTP Host to be used for sending the current message. |
int | getSMTP_Port()
Returns the SMTP Port to be used for sending the current message. |
java.lang.String | getSubject()
Returns the Subject header associated with the current message. |
java.util.Vector | getTo()
Returns a Vector of all TO addresses currently associated with this MimeMessage. The method will return an empty Vector (not a null), if no address have yet been set. |
java.lang.String | getXMailerHeader()
Gets the X-Mailer header for this message. Generally, this header is used to provide information about the kind of software used to send the message. NOTE: Some mail client programs do not show these headers. |
java.util.Vector | listAttachments()
Returns a collection of java.io.File
objects included in this message's attachments.
|
java.util.Vector | listAttachmentsDescriptions()
Returns a collection of Strings
which are the file descriptions associated with this message's attachments.
|
java.util.Vector | listAttachmentsMimes()
Returns a collection of Strings
which are the file mime types associated with this message's attachments.
|
java.util.Vector | listAttachmentsNames()
Returns a collection of Strings
which are the file file names associated with this message's attachments.
|
boolean | MailSent()
A boolean to be called after ConstructAndSend() to determine whether the message was actually sent. This method can be invoked if you wish to avoid having to read the String returned by the ConstructAndSend() method. |
void | removeAllAttachments()
Removes all attachments from the current message. |
java.lang.String | removeAttachment(int
attIndex)
Removes the attachment located at index attIndex from this message's Vector of attachments. This should provide an easy to follow parallel for attachments managed through JComboBox or JList interfaces. |
void | setAddressException(java.lang.String
aes)
Sets the the message to be shown in the event a javax.mail.internet.AddressException occurs with one or more addresses. |
void | setBadBCCWarning(java.lang.String
bbw)
Sets the message to be shown the client if an invalid BCC address has been provided, and an attempt was made to send the mail. If this error occurs, the ConstructAndSend() method will return THIS string instead of a success message.This method helps avoid unnecessary AddressExceptions and provides the client with a specific explanation for why his/her email was rejected. |
void | setBadCCWarning(java.lang.String
bcw)
Sets the message to be shown the client if an invalid CC address has been provided, and an attempt was made to send the mail. If this error occurs, the ConstructAndSend() method will return THIS string instead of a success message. This method helps avoid unnecessary AddressExceptions and provides the client with a specific explanation for why his/her email was rejected. |
void | setBadFROMWarning(java.lang.String
bdfw)
Sets the message to be shown the client if an invalid FROM address has been provided, and an attempt was made to send the mail. If this error occurs, the ConstructAndSend() method will return THIS string instead of a success message. This method helps avoid unnecessary AddressExceptions and provides the client with a specific explanation for why his/her email was rejected. |
void | setBadTOWarning(java.lang.String
btw)
Sets the message to be shown the client if an invalid TO address has been provided, and an attempt was made to send the mail. If this error occurs, the ConstructAndSend() method will return THIS string instead of a success message. This method helps avoid unnecessary AddressExceptions and provides the client with a specific explanation for why his/her email was rejected. |
void | setBcc(java.util.Vector
Bcc)
Adds the specified Vector to the message's list of BCC addresses: Vector adds=new Vector();
This method could prove very useful for easily parsing a long list of BCC addresses into the message's BCC field. |
void | setCc(java.util.Vector
Cc)
Adds the specified Vector to the message's list of CC addresses: Vector adds=new Vector();
This method could prove very useful for easily parsing a long list of CC addresses into the message's CC field. |
void | setDefaultMimeType(java.lang.String
dmt)
CHANGING THE MIME-TYPE (for
HTML Mail etc.):
Please note, that as of this writing, only JavaMail version 1.1.3 and above supports text/html. |
void | setExtraHeaderLine(java.lang.String
exl)
Adds an extra mail header line of your choose to the message. NOTE: Not all mail clients show message headers. |
void | setFrom(java.lang.String
fr)
Sets the FROM field of the mail message. |
void | setGreenLight(boolean
green)
Not implimented. |
void | setMailSuccessMessage(java.lang.String
msm)
Sets the text message to be shown the client upon successful sending of a message. |
void | setMessage(java.lang.String
msg)
Sets the text message to be included in the current MimeMessage. |
void | setMessageException(java.lang.String
mes)
Sets the message to be displayed to the client in the event a javax.mail.MessagingException occurs. |
void | setMSMailPriority(java.lang.String
msmail)
Sets the mail priority understood
by most Microsoft mail clients.
|
void | setNetscapeMailPriority(java.lang.String
nmail)
Sets the mail priority understood
by most Netscape mail clients.
|
void | setNoFROMWarning(java.lang.String
nfw)
Sets the message to be shown the client if no FROM address has been provided, but an attempt was made to send the mail. If this error occurs, the ConstructAndSend() method will return THIS string instead of a success message. |
void | setNoMessageWarning(java.lang.String
nmw)
Sets the message to be shown the client if no message body has been provided, but an attempt was made to send the mail. If this error occurs, the ConstructAndSend() method will return THIS string instead of a success message. |
void | setNoTOWarning(java.lang.String
ntw)
Sets the message to be shown the client if no TO address has been provided, but an attempt was made to send the mail. If this error occurs, the ConstructAndSend() method will return THIS string instead of a success message. |
void | setSenderInfo(java.lang.String
si)
Sets any extra sender information you have choose to attach to the bottom of the current message. This method is useful for, say, attaching information about the sender's IP address, or web browser type to the message. The information will appear beloew the main message body. This value is NOT null by default, so if you don't wish to see a default message below the email's body, you should adjust this information to your liking. |
void | setSessionProperties(java.util.Properties
prp, javax.mail.Authenticator au)
ALLOWS FOR OVERIDDING THE SESSION COMPLETELY / USING AUTHENTICATORS:
mail.setSessionProperties(MyProperties, MyAuthenticator);
This method will automatically create a new Session to accommodate your
changes.
|
void | setSMTP_Host(java.lang.String
hst)
Sets the SMTP host from which to send the email message. |
void | setSMTP_Port(int
prt)
Sets the SMTP port from which to send the email message. |
void | setSubject(java.lang.String
subj)
Sets the message's Subject field. |
void | setTo(java.util.Vector
To)
Adds the specified Vector to the message's list of TO addresses: Vector adds=new Vector();
This method could prove very useful for easily parsing a long list of TO addresses into the message's TO field. |
void | setXMailerHeader(java.lang.String
xmail)
Sets the X-Mailer header for this message. Generally, this header is used to provide information about the kind of software used to send the message. NOTE: Some mail client programs do not show these headers. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Mailer()
Method Detail |
public boolean MailSent()
public void setSMTP_Host(java.lang.String hst)
public java.lang.String getSMTP_Host()
public void setSMTP_Port(int prt)
public int getSMTP_Port()
public void setTo(java.util.Vector To)
public java.util.Vector getTo()
public void setFrom(java.lang.String fr)
public java.lang.String getFrom()
public void setCc(java.util.Vector Cc)
public java.util.Vector getCc()
public void setBcc(java.util.Vector Bcc)
public java.util.Vector getBcc()
public void setSubject(java.lang.String subj)
public java.lang.String getSubject()
public void setMessage(java.lang.String msg)
public java.lang.String getMessage()
public void setBadFROMWarning(java.lang.String bdfw)
public java.lang.String getBadFROMWarning()
public void setBadTOWarning(java.lang.String btw)
public java.lang.String getBadTOWarning()
public void setBadCCWarning(java.lang.String bcw)
public java.lang.String getBadCCWarning()
public void setBadBCCWarning(java.lang.String bbw)
public java.lang.String getBadBCCWarning()
public void setNoFROMWarning(java.lang.String nfw)
public java.lang.String getNoFROMWarning()
public void setNoMessageWarning(java.lang.String nmw)
public java.lang.String getNoMessageWarning()
public void setNoTOWarning(java.lang.String ntw)
public java.lang.String getNoTOWarning()
public void setXMailerHeader(java.lang.String xmail)
public java.lang.String getXMailerHeader()
public void setGreenLight(boolean green)
public boolean getGreenLight()
public void setMSMailPriority(java.lang.String msmail)
public java.lang.String getMSMailPriority()
public void setNetscapeMailPriority(java.lang.String nmail)
public java.lang.String getNetscapeMailPriority()
public void setMailSuccessMessage(java.lang.String msm)
public java.lang.String getMailSuccessMessage()
public void setMessageException(java.lang.String mes)
public java.lang.String getMessageException()
public void setAddressException(java.lang.String aes)
public java.lang.String getAddressException()
public void setSenderInfo(java.lang.String si)
public java.lang.String getSenderInfo()
public void setDefaultMimeType(java.lang.String dmt)
public java.lang.String getDefaultMimeType()
public void setExtraHeaderLine(java.lang.String exl)
public java.lang.String getExtraHeaderLine()
public java.lang.String ConstructAndSend(boolean ConstructOnly_NoSend)
public javax.mail.internet.MimeMessage getRawMimeMessage()
public javax.mail.Session getMessageSession()
public void addAttachment(java.io.File data_to_be_attached, java.lang.String mimetype, java.lang.String file_name, java.lang.String file_description)
public void removeAllAttachments()
public java.lang.String removeAttachment(int ai)
public java.util.Vector listAttachments()
public java.util.Vector listAttachmentsMimes()
public java.util.Vector listAttachmentsNames()
public java.util.Vector listAttachmentsDescriptions()
public void setSessionProperties(java.util.Properties prp, javax.mail.Authenticator au)
public java.util.Properties getSessionProperties()
public void ClearOldMessage()
public void addTO(java.lang.String new_TO)
public void addBCC(java.lang.String new_BCC)
public void addCC(java.lang.String new_CC)
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |