|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.java4less.rmail.MailMsg
This class represents an e-mail message. In order to send a mail you must create one instance onf this class and call the "mail()" mehtod. Example:
Sending an email and attachment
This is a sample source code to send an email:
m=new MailMsg(); // create email
m.from="user1@mycompany.com"; // sender and receiver
m.addRecipient("user2@mycompany.com");
m.subject="test";
part=new MainMsgPart(); // add text part
part.setData("This is the text",MimeEncoder.QUOTED);
part.addPart(part);
m.addFile(new java.io.File("c:\\mydocument.doc")); // add attachment
m.smtpServer="smtp.mycompany.com";
m.mail(); // send mail
Sending alternative parts (Text and HTML)
This is a sample source code to send an email which contains two versions of the text (plain text and html):
m=new MailMsg(); // create email
m.from="user1@mycompany.com"; // sender and receiver
m.addRecipient("user2@mycompany.com");
m.subject="test";
part=new MainMsgPart(); // create alternative
part.ContentType="Multipart";
part.ContentSubType="Alternative";
textpart=new MainMsgPart(); // add text part to the alternative
textpart.setData("This is the text",MimeEncoder.QUOTED);
part.addPart(textpart);
htmlpart=new MainMsgPart(); // add html part to the alternative
htmlpart.ContentType="Multipart";
htmlpart.ContentSubType="Alternative";
htmlpart.setData("<html><body>This is the text</body></html>",MimeEncoder.QUOTED);
part.addPart(htmlpart);
m.addPart(part);
m.smtpServer="smtp.mycompany.com";
m.mail(); // send mail
Inner Class Summary | |
class |
MailMsg.SMTP
|
Field Summary | |
int |
AUTH_LOGIN
|
int |
AUTH_NONE
|
int |
AUTH_PLAIN
|
java.lang.String |
authPwd
smtp authentication password, see also autMethod |
java.lang.String |
authUser
smtp authentication user, see also autMethod |
int |
autMethod
authentication method, AUTH_LOGIN, AUTH_PLAIN or AUTH_NONE |
java.lang.String |
charSet
Set of characters to be used. |
java.lang.String |
ContentSubType
Content subtype of the e-mail. |
java.lang.String |
ContentType
Content type of the e-mail. |
boolean |
debug
debug |
java.lang.String |
FileName
|
java.lang.String |
from
e-mail address of the sender (e.g. user@company.com). |
ProgressSMTPListener |
liste
listener of the message. |
java.lang.String |
msgId
id of the message. |
java.lang.String |
nameFrom
name of the sender of the mail |
java.lang.String[] |
otherFields
Additional header fields in rfc822 format that should be sent. |
int |
partCounter
number of parts in the message. |
java.lang.String |
rawHDR
Header of the message as sent or received |
java.lang.String |
rawMsg
Message as sent or received |
java.lang.String |
replyTo
address to reply to. |
java.lang.String |
smtpDate
date field of the smtp message. |
java.lang.String |
smtpMyAddress
name/address of the computer sending the mail. |
int |
smtpPort
smpt port to connect to. |
java.lang.String |
smtpServer
smtpServer where to send the e-mail. |
java.lang.String |
smtpStatus
description of the current status of the connection. |
java.lang.String |
subject
subject of the e-mail. |
java.lang.String |
timeZoneStr
time zone to be inserted in the date of the e-mail. |
Constructor Summary | |
MailMsg()
|
Method Summary | |
void |
addBCC(java.lang.String dest)
adds a blind copy recipient. |
void |
addCC(java.lang.String dest)
adds a carbon copy recipient. |
boolean |
addFile(java.io.File f)
adds a new message part that will contain a file. |
void |
addPart(MailMsgPart p)
add a new message part. |
void |
addRecipient(java.lang.String dest)
adds a message recipient. |
MailMsgPart |
getPart(int num)
|
int |
mail()
sends the message. |
static void |
MailMsg()
creates a a new mail message. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public java.lang.String from
public java.lang.String nameFrom
public java.lang.String subject
public java.lang.String smtpServer
public java.lang.String timeZoneStr
public java.lang.String replyTo
public java.lang.String msgId
public java.lang.String charSet
public java.lang.String ContentType
public java.lang.String ContentSubType
Content subtype of the e-mail. This must have a value if the Content type has a value. Valid combinations of type / subtype are:
or any other valid Mime type.
public java.lang.String[] otherFields
Additional header fields in rfc822 format that should be sent. For example:
"X-Sender: bwinters"
public java.lang.String smtpStatus
public java.lang.String smtpMyAddress
public int smtpPort
public java.lang.String rawHDR
public java.lang.String rawMsg
public ProgressSMTPListener liste
listener of the message. This listener receives the status of the connection when it changes, it sould only be used for feedback (visualization) purposes.
public java.lang.String FileName
public java.lang.String smtpDate
public java.lang.String authUser
public java.lang.String authPwd
public final int AUTH_LOGIN
public final int AUTH_PLAIN
public final int AUTH_NONE
public int autMethod
public int partCounter
public boolean debug
Constructor Detail |
public MailMsg()
Method Detail |
public static void MailMsg()
public MailMsgPart getPart(int num)
public boolean addFile(java.io.File f)
public void addPart(MailMsgPart p)
public void addRecipient(java.lang.String dest)
public void addCC(java.lang.String dest)
public void addBCC(java.lang.String dest)
public int mail()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |