biz.wisesoft.util.mail
Class EmailMessage

java.lang.Object
  extended bybiz.wisesoft.util.mail.EmailMessage

public class EmailMessage
extends java.lang.Object

This class represents an email message. To send an email you only need create one instance onf this class and call the "sendMail()" mehtod.
Example:

    EmailMessage em=new EmailMessage();    
    em.from="wisesoft@wisesoft.biz";
    em.addRecipient("user@wisesoft.biz");
    //debug
    em.debug=true;
    //-------SMTP Authentication-----
    em.authUser="jim";
    em.authPwd="12345678";
    em.autMethod=m.AUTH_LOGIN;
    //-------------------------------
    em.subject="test";
    MsgPart part=new MsgPart();
    part.setData("This is the text",MimeEncoder.QUOTED);
    part.addPart(part);
    em.addFile(new java.io.File("c:\\file.doc"));  
    em.smtpServer="smtp.hotpop.com";
    em.sendMail();   
 
   //This is a sample to send an email which contains two parts
    EmailMessage em=new EmailMessage();
    em.from="user@abc.com";          
    em.addRecipient("user@ms.com");
    em.subject="test"; 
    MsgPart part=new MsgPart();
    part.ContentType="Multipart";
    part.ContentSubType="Alternative"; 
    MsgPart textpart=new MsgPart();
    textpart.setData("This is the text",MimeEncoder.QUOTED);
    part.addPart(textpart); 
    MsgPart htmlpart=new MsgPart();    
    htmlpart.ContentType="Multipart";
    htmlpart.ContentSubType="Alternative";
    htmlpart.setData("This is the html text",MimeEncoder.QUOTED);
    part.addPart(htmlpart); 
    em.addPart(part);
    em.smtpServer="smtp.hotpop.com";
    em.sendMail();   
 


Nested Class Summary
 class EmailMessage.SMTP
           
 
Field Summary
 int AUTH_LOGIN
           
 int AUTH_NONE
           
 int AUTH_PLAIN
           
 java.lang.String authPwd
           
 java.lang.String authUser
           
 int autMethod
           
 java.lang.String charSet
          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
           
 java.lang.String FileName
           
 java.lang.String from
          Sender's email address.
 java.lang.String jMsg
          Message as sent.
 biz.wisesoft.util.mail.JvInterface liste
          listener of the message.
 java.lang.String mailHeader
          Header of the message as sent.
 java.lang.String msgId
          Id of the message
 java.lang.String nameFrom
           
 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 replyTo
          Address of the replyto.
 java.lang.String smtpDate
          Date field of the smtp message.
 java.lang.String smtpOwnAddress
          Name or address of the computer sending the mail.
 int smtpPort
          Smpt port to connect to.
 java.lang.String smtpServer
          The SMTP Server used to send the e-mail.
 java.lang.String smtpStatus
          Description of the current status of the connection.
 java.lang.String subject
          Subject of the email.
 java.lang.String timeZoneStr
          Time zone to be inserted in the date of the email.
 
Constructor Summary
EmailMessage()
          Creates a a new mail message.
 
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 filepart)
          Adds a new message part that will contain a file.
 void addPart(MsgPart p)
          Add a new message part
 void addRecipient(java.lang.String dest)
          Adds a message recipient.
 MsgPart getPart(int num)
           
static void MailMsg()
           
 int sendMail()
          Sends the message.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

from

public java.lang.String from
Sender's email address.


nameFrom

public java.lang.String nameFrom

subject

public java.lang.String subject
Subject of the email.


smtpServer

public java.lang.String smtpServer
The SMTP Server used to send the e-mail.


timeZoneStr

public java.lang.String timeZoneStr
Time zone to be inserted in the date of the email.


replyTo

public java.lang.String replyTo
Address of the replyto.


msgId

public java.lang.String msgId
Id of the message


charSet

public java.lang.String charSet
Characters to be used.


ContentType

public java.lang.String ContentType
Content type of the e-mail


ContentSubType

public java.lang.String ContentSubType
Content subtype of the e-mail.


otherFields

public java.lang.String[] otherFields
Additional header fields in rfc822 format that should be sent.


smtpStatus

public java.lang.String smtpStatus
Description of the current status of the connection.


smtpOwnAddress

public java.lang.String smtpOwnAddress
Name or address of the computer sending the mail.


smtpPort

public int smtpPort
Smpt port to connect to.


mailHeader

public java.lang.String mailHeader
Header of the message as sent.


jMsg

public java.lang.String jMsg
Message as sent.


liste

public biz.wisesoft.util.mail.JvInterface liste
listener of the message.


FileName

public java.lang.String FileName

smtpDate

public java.lang.String smtpDate
Date field of the smtp message.


authUser

public java.lang.String authUser

authPwd

public java.lang.String authPwd

AUTH_LOGIN

public final int AUTH_LOGIN
See Also:
Constant Field Values

AUTH_PLAIN

public final int AUTH_PLAIN
See Also:
Constant Field Values

AUTH_NONE

public final int AUTH_NONE
See Also:
Constant Field Values

autMethod

public int autMethod

partCounter

public int partCounter
number of parts in the message


debug

public boolean debug
Constructor Detail

EmailMessage

public EmailMessage()
Creates a a new mail message.

Method Detail

MailMsg

public static void MailMsg()

getPart

public MsgPart getPart(int num)

addFile

public boolean addFile(java.io.File filepart)
Adds a new message part that will contain a file.

Parameters:
filepart - a file
Returns:
if hasn't error returns "true"

addPart

public void addPart(MsgPart p)
Add a new message part

Parameters:
p - The message part

addRecipient

public void addRecipient(java.lang.String dest)
Adds a message recipient.

Parameters:
dest - The message recipient

addCC

public void addCC(java.lang.String dest)
Adds a carbon copy recipient.

Parameters:
dest - The carbon copy recipient

addBCC

public void addBCC(java.lang.String dest)
Adds a blind copy recipient.

Parameters:
dest - The blind copy recipient

sendMail

public int sendMail()
Sends the message.