|
MDi JLib 1.7.4 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.microdeveloper.util.net.mail.JMail
public class JMail
Provides functions for sending E-mail with various MIME type encodings and optional attachements. The class can be used in static form where the variables are all passed in, or as a bean where the properties of the E-mail are first set, then the message is sent.
Field Summary | |
---|---|
static String |
DEFAULTHOST
|
static String |
HTML
|
static String |
HTML_MIMETYPE
|
static String |
MULTIPART
|
static String |
PLAIN
|
static String |
PLAIN_MIMETYPE
|
Constructor Summary | |
---|---|
JMail()
Creates a new JMail object using the properties defined in the defaut mail properties file |
Method Summary | |
---|---|
String |
getAttachment()
Returns the currently attachment. |
String |
getBcc()
Returns the currently established BCC list |
String |
getBody()
Returns the message body |
String |
getCc()
Returns the currently established CC list |
String |
getCharacterSet()
Returns the current character set being used |
javax.mail.BodyPart |
getFileBodyPart(String filename,
String contentType)
Fetches a particular body part from the current message. |
String |
getFrom()
Returns the currently established from address |
String |
getHost()
Returns the currenty SMTP host. |
String |
getHtmlBody()
Returns the HTML message body |
JMailInterface |
getjMailInterface()
Returns the interfacce to the class |
String |
getMailPropertiesPath()
Fetches the currently established properties path. |
String |
getPlainBody()
Returns the plain message body |
String |
getSmtpHost()
Returns the currenty SMTP host |
String |
getSubject()
Returns the message subject |
String |
getTo()
Returns the currently established To list |
boolean |
isDebugging()
Returns the current state of debugging. |
void |
sendMail()
Sends the current mail message using a plain text format or the format the mime type is currently set to |
static void |
sendMail(String from,
String to,
String cc,
String bcc,
String subject,
String body)
Sends a plain text message. |
static void |
sendMail(String from,
String to,
String cc,
String bcc,
String subject,
String body,
String mimeType)
Sends a message of the type specified in mimeType. |
static void |
sendMail(String from,
String to,
String cc,
String bcc,
String subject,
String body,
String mimeType,
String host,
boolean debug)
Sends a plain text message. |
void |
sendMultipart()
Sends the current mail message using a multipart format. |
static void |
sendMultipart(String from,
String to,
String cc,
String bcc,
String subject,
String body,
String altBody)
Sends a multi-part E-mail message. |
static void |
sendMultipart(String from,
String to,
String cc,
String bcc,
String subject,
String body,
String altBody,
String attachments,
String host,
boolean debug)
Sends a multi-part E-mail message. |
void |
setBcc(String bcc)
Sets the message recipients in the BCC (blind carbon copy) segment of the E-mail. |
void |
setBody(String body)
Sets the body segment of the E-mail using the format defined in the mime type property. |
void |
setCc(String cc)
Sets the message recipients in the CC (carbon copy) segment of the E-mail. |
void |
setCharacterSet(String value)
Sets the character set used for the message |
void |
setDebug(boolean debug)
Sets the debug state |
void |
setFrom(String from)
Sets the message senders in the From segment of the E-mail. |
void |
setHost(String host)
Sets the SMTP host using either an IP address or a host name. |
void |
setHtmlBody(String htmlBody)
Sets the HTML body segment of the E-mail for rich text messages. |
void |
setMailPropertiesPath(String value)
Sets the name and location of the JMail properties file |
void |
setMimeType(String value)
Sets the specific mime type for the message |
void |
setPlainBody(String plainBody)
Sets the text body segment of the E-mail using plain text. |
void |
setSmtpHost(String host)
Sets the SMTP host using either an IP address or a host name. |
void |
setSubject(String subject)
Sets the subject of the message. |
void |
setTo(String to)
Sets the message recipients in the To segment of the E-mail. |
void |
setType(String type)
Sets the type of message. |
static String |
vectorToString(Vector v)
Converts the given vector to a String object |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String DEFAULTHOST
public static final String HTML
public static final String HTML_MIMETYPE
public static final String MULTIPART
public static final String PLAIN
public static final String PLAIN_MIMETYPE
Constructor Detail |
---|
public JMail()
Method Detail |
---|
public static void sendMail(String from, String to, String cc, String bcc, String subject, String body)
from
- from sender e-mail address(es)to
- to recipient e-mail address(es)cc
- cc recipient e-mail address(es)bcc
- bcc recipient e-mail address(es)subject
- subject of the messagebody
- content of the message (message body)public static void sendMail(String from, String to, String cc, String bcc, String subject, String body, String mimeType)
from
- from sender e-mail address(es)to
- to recipient e-mail address(es)cc
- cc recipient e-mail address(es)bcc
- bcc recipient e-mail address(es)subject
- subject of the messagebody
- content of the message (message body)mimeType
- mime type to use when encoding the messagepublic static void sendMail(String from, String to, String cc, String bcc, String subject, String body, String mimeType, String host, boolean debug)
from
- from sender e-mail address(es)to
- to recipient e-mail address(es)cc
- cc recipient e-mail address(es)bcc
- bcc recipient e-mail address(es)subject
- subject of the messagebody
- content of the message (message body)mimeType
- mime type to use when encoding the messagehost
- smtp mail server host IP or namedebug
- set to true for debugging output or false (default)public static void sendMultipart(String from, String to, String cc, String bcc, String subject, String body, String altBody) throws IOException, javax.mail.MessagingException
from
- from sender e-mail address(es)to
- to recipient e-mail address(es)cc
- cc recipient e-mail address(es)bcc
- bcc recipient e-mail address(es)subject
- subject of the messagebody
- content of the message as text (message body)altBody
- content of the message as HTML (rich text message body)
javax.mail.internet.AddressException
- thrown if any of the addresses are improperly formatted
FileNotFoundException
- thrown when the configuration file cannot be found
IOException
- thrown when the IO cannot be opened or accessed
javax.mail.MessagingException
- thrown if the mail message cannot be sent for some reasonpublic static void sendMultipart(String from, String to, String cc, String bcc, String subject, String body, String altBody, String attachments, String host, boolean debug) throws IOException, javax.mail.MessagingException
This variant also allows the user to specify the host, set debug settings and add attachments*.
*not enabled
from
- from sender e-mail address(es)to
- to recipient e-mail address(es)cc
- cc recipient e-mail address(es)bcc
- bcc recipient e-mail address(es)subject
- subject of the messagebody
- content of the message as text (message body)altBody
- content of the message as HTML (rich text message body)attachments
- attachment file listhost
- smtp mail server host IP address or namedebug
- set to true to enable debugging output
javax.mail.internet.AddressException
- thrown if any of the addresses are improperly formatted
FileNotFoundException
- thrown when the configuration file cannot be found
IOException
- thrown when the IO cannot be opened or accessed
javax.mail.MessagingException
- thrown if the mail message cannot be sent for some reason
javax.mail.internet.AddressException
- thrown if any of the addresses are improperly formatted
FileNotFoundException
- thrown when the configuration file cannot be found
IOException
- thrown when the IO cannot be opened or accessed
javax.mail.MessagingException
- thrown if the mail message cannot be sent for some reasonpublic static String vectorToString(Vector v)
v
- vector to convert
public JMailInterface getjMailInterface()
public void sendMail()
public void sendMultipart()
public void setTo(String to)
to
- one or more E-mail addressespublic void setFrom(String from)
from
- one or more E-mail addressespublic void setCc(String cc)
cc
- one or more E-mail addressespublic void setBcc(String bcc)
bcc
- one or more E-mail addressespublic void setHtmlBody(String htmlBody)
htmlBody
- the body of the message using HTML formattingpublic void setPlainBody(String plainBody)
plainBody
- the body of the message using plain text formattingpublic void setBody(String body)
body
- the body of the messagepublic void setSubject(String subject)
subject
- text to use for the subjectpublic void setType(String type)
type
- one of the constant typespublic void setSmtpHost(String host)
host
- host name or addresspublic void setHost(String host)
host
- host name or addresspublic void setMailPropertiesPath(String value)
value
- name and path to the JMail properties filepublic void setMimeType(String value)
value
- a supported mimetypepublic void setCharacterSet(String value)
value
- a supported character setpublic void setDebug(boolean debug)
debug
- true for debugging otherwise falsepublic javax.mail.BodyPart getFileBodyPart(String filename, String contentType) throws javax.mail.MessagingException
filename
- filename of the attachmentcontentType
- content type to fetch
javax.mail.MessagingException
- thrown if the body part cannot be fetchedpublic String getMailPropertiesPath()
public String getTo()
public String getFrom()
public String getCc()
public String getBcc()
public String getAttachment()
public boolean isDebugging()
public String getCharacterSet()
public String getSubject()
public String getBody()
public String getPlainBody()
public String getHtmlBody()
public String getSmtpHost()
public String getHost()
|
MDi JLib 1.7.4 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |