All Packages Class Hierarchy This Package Previous Next Index
java.lang.Object | +----MSBMail.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
public String from
e-mail address of the sender (e.g. user@company.com).
public String subject
subject of the e-mail.
public String smtpServer
smtpServer where to send the e-mail.
public String timeZoneStr
time zone to be inserted in the date of the e-mail. The default is GMT.
public String replyTo
address to reply to.
public String msgId
id of the message. If empty the system will create one.
public String charSet
Set of characters to be used. The default is "us-ascii". Other possible are: iso-8859-1, iso-8859-2 ...
public String ContentType
Content type of the e-mail. This value if optional. If the email has more one part its value will be "multipart". Other values are: "Text" (the mail contains text), "Message" (it contains another message), or "Application" (it contains binary data).
public 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 String otherFields[]
Additional header fields in rfc822 format that should be sent. For example:
"X-Sender: bwinters"
public String smtpStatus
description of the current status of the connection. It should only be used for user feedback.
public String smtpMyAddress
name/address of the computer sending the mail.
public int smtpPort
smpt port to connect to. The default is 25.
public String rawHDR
Header of the message as sent or received
public String rawMsg
Message as sent or received
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 String smtpDate
date field of the smtp message. For example: 5 May 2000 15:58:38 -0500. This field is automatically calculated if empty.
public int partCounter
number of parts in the message.
public MailMsg()
creates a a new mail message.
public void addBCC(String dest)
adds a blind copy recipient.
public void addCC(String dest)
adds a carbon copy recipient.
public boolean addFile(File f)
adds a new message part that will contain a file.
public void addPart(MailMsgPart p)
add a new message part.
public void addRecipient(String dest)
adds a message recipient.
public MailMsgPart getPart(int num)
extracts a message part.
public int mail()
send the message.
public static void MailMsg()
All Packages Class Hierarchy This Package Previous Next Index