biz.wisesoft.util.mail
Class MsgPart

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

public class MsgPart
extends java.lang.Object

An email message is always made of parts.This is a part of message. In the simplest case there is just one part that contains text, however sometimes one part can contain a file (binary data), a HTML page or other parts (type multipart).
Example:
this is an example part that contains html data:

    MsgPart htmlpart=new MsgPart();   
    htmlpart.ContentType="Text";
    htmlpart.ContentSubType="Html";
    htmlpart.setData("This is the html text",MimeEncoder.QUOTED);
 
this is a example part that contains binary data:
    byte[] binaryData=new {55,21,25,65,51};
    part=new MsgPart();   
    part.ContentType="Application";
    part.ContentSubType="Octet-stream";
    part.setBinaryData(binaryData,MimeEncoder.BASE64);
 


Field Summary
 java.lang.String boundary
          Boundary used to separate subparts
 java.lang.String ContentSubType
          Content subtype of the e-mail
values:
* Text / Plain
* Text / Html
* Message / rfc822
* Application / Octets-stream
* Application / Images
and so forth
 java.lang.String ContentType
          MIME style ContentType string
This value if optional.
 int Encoding
          Encoding type
 java.lang.String FileName
          File name if the part has "Application" ContentType.
 java.lang.String header
          Header of the part
 int partCounter
          Number of subparts in the part
 java.lang.String partName
          Name of part
 
Constructor Summary
MsgPart()
          Constructor
 
Method Summary
 void addPart(MsgPart mailMsgPart)
           
 java.lang.String getData()
          Returns the content of the mail body
 java.lang.String getHeader()
           
 MsgPart getPart(int num)
           
 boolean saveToFile(java.lang.String pkfile)
           
 void setBinaryData(byte[] binaryData)
           
 void setCodedData(java.lang.String d)
           
 void setData(java.lang.String data, int encoding)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ContentType

public java.lang.String ContentType
MIME style ContentType string
This value if optional.
values:
* Message-The mail contains another message
* Application-The mail contains binary data
* multipart-The mail has more than one part
* Text-THe mail contains test


ContentSubType

public java.lang.String ContentSubType
Content subtype of the e-mail
values:
* Text / Plain
* Text / Html
* Message / rfc822
* Application / Octets-stream
* Application / Images
and so forth


Encoding

public int Encoding
Encoding type


partName

public java.lang.String partName
Name of part


partCounter

public int partCounter
Number of subparts in the part


FileName

public java.lang.String FileName
File name if the part has "Application" ContentType.


header

public java.lang.String header
Header of the part


boundary

public java.lang.String boundary
Boundary used to separate subparts

Constructor Detail

MsgPart

public MsgPart()
Constructor

Method Detail

setCodedData

public void setCodedData(java.lang.String d)

getPart

public MsgPart getPart(int num)

addPart

public void addPart(MsgPart mailMsgPart)
Parameters:
mailMsgPart - MailMsg Part
Adds a subpart to the part.

setBinaryData

public void setBinaryData(byte[] binaryData)
Parameters:
binaryData - sets the binary content of the part which will be encoded with BASE64.

setData

public void setData(java.lang.String data,
                    int encoding)
Parameters:
data - The data of mail body
encoding - The encoding type Sets the content of the part if not binary, you must specify an encoding method:
Encoding types include below:
* MimeEncoder.NO_ENCODE
* MimeEncoder.QUOTED
* MimeEncoder.BASE64

getData

public java.lang.String getData()
Returns the content of the mail body

Returns:
The data of mail body

saveToFile

public boolean saveToFile(java.lang.String pkfile)
Parameters:
pkfile - The file name
Returns:
If saved successfully, returns true,otherwise returns false
Saves the content of the part to a file.

getHeader

public java.lang.String getHeader()
Returns:
The header of the part in rfc822 format.