All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class MSBMail.MailMsg

java.lang.Object
   |
   +----MSBMail.MailMsg

public class MailMsg
extends Object

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

 

 


Variable Index

 o charSet
 o ContentSubType
 o ContentType
 o from
 o liste
 o msgId
 o otherFields
 o partCounter
 o rawHDR
 o rawMsg
 o replyTo
 o smtpDate
 o smtpMyAddress
 o smtpPort
 o smtpServer
 o smtpStatus
 o subject
 o timeZoneStr

Constructor Index

 o MailMsg()

Method Index

 o addBCC(String)
 o addCC(String)
 o addFile(File)
 o addPart(MailMsgPart)
 o addRecipient(String)
 o getPart(int)
 o mail()
 o MailMsg()

Variables

 o from
 public String from
e-mail address of the sender (e.g. user@company.com).
 o subject
 public String subject
subject of the e-mail.
 o smtpServer
 public String smtpServer
smtpServer where to send the e-mail.
 o timeZoneStr
 public String timeZoneStr
time zone to be inserted in the date of the e-mail. The default is GMT.
 o replyTo
 public String replyTo
address to reply to.
 o msgId
 public String msgId
id of the message. If empty the system will create one.
 o charSet
 public String charSet
Set of characters to be used. The default is "us-ascii". Other possible are: iso-8859-1, iso-8859-2 ...
 o ContentType
 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).

 

 o ContentSubType
 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.

 

 o otherFields
 public String otherFields[]
Additional header fields in rfc822 format that should be sent. For example:
"X-Sender: bwinters"
 o smtpStatus
 public String smtpStatus
description of the current status of the connection. It should only be used for user feedback.
 
 o smtpMyAddress
 public String smtpMyAddress
name/address of the computer sending the mail.
 o smtpPort
 public int smtpPort
smpt port to connect to. The default is 25.
 o rawHDR
 public String rawHDR
Header of the message as sent or received
 o rawMsg
 public String rawMsg
Message as sent or received
 o liste
 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.

 
 o smtpDate
 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.

 o partCounter
 public int partCounter
number of parts in the message.

Constructors

 o MailMsg
 public MailMsg()
creates a a new mail message.

Methods

 o addBCC
 public void addBCC(String dest)
adds a blind copy recipient.
 o addCC
 public void addCC(String dest)
adds a carbon copy recipient.
 o addFile
 public boolean addFile(File f)
adds a new message part that will contain a file.
 o addPart
 public void addPart(MailMsgPart p)
add a new message part.
 o addRecipient
 public void addRecipient(String dest)
adds a message recipient.
 o getPart
 public MailMsgPart getPart(int num)
extracts a message part.
 o mail
 public int mail()
send the message.
 o MailMsg
 public static void MailMsg()

All Packages  Class Hierarchy  This Package  Previous  Next  Index