com.java4less.rmail
Class MailMsgPart

java.lang.Object
  |
  +--com.java4less.rmail.MailMsgPart

public class MailMsgPart
extends java.lang.Object

This is a part of an e-mail. A message is always made of parts. In the simplest case there is just one part that contains text, however one part can contain a file (binary data), a HTML page or other parts (type multipart).

For example, this is a part that contains text:

textpart=new MainMsgPart();                                  
textpart.setData("This is the text",MimeEncoder.QUOTED);
part.addPart(textpart);

this is a part that contains html data:

htmlpart=new MainMsgPart();                                  
htmlpart.ContentType="Text";
htmlpart.ContentSubType="Html";
htmlpart.setData("<html><body>This is the text</body></html>",MimeEncoder.QUOTED);

this is a part that contains binary data:

byte[] binaryData=new {34,13,10,80};

part=new MainMsgPart();                                  
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
          see ContentSubType of MailMsg
 java.lang.String ContentType
          see ContentType of MailMsg
 int Encoding
          Current encoding of the part.
 java.lang.String FileName
          File name if the part has "Application" ContentType.
 java.lang.String Name
          Name of the part.
 int partCounter
          number of subparts in the part (if ContentType is "Multipart").
 java.lang.String rawHDR
          header of the part as sent or received.
 
Constructor Summary
MailMsgPart()
           
 
Method Summary
 void addPart(MailMsgPart p)
          Adds a subpart to the part.
 byte[] getBinaryData()
          returns binary content of the file.
 java.lang.String getData()
          returns the non-binary content.
 java.lang.String getHeader()
          returns the header of the part in rfc822 format.
 MailMsgPart getPart(int num)
          returns a subparft of the part.
 boolean saveToFile(java.lang.String psFile)
          saves the content of the part to a file.
 void setBinaryData(byte[] b)
          sets the binary content of the part.
 void setCodedData(java.lang.String d)
          method called by the POP connection to store the received data.
 void setData(java.lang.String d, int encoding)
          sets the content of the part if not binary, you must specify an encoding method: MimeEncoder.NO_ENCODE. MimeEncoder.QUOTED.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ContentType

public java.lang.String ContentType
see ContentType of MailMsg

ContentSubType

public java.lang.String ContentSubType
see ContentSubType of MailMsg

Encoding

public int Encoding
Current encoding of the part. The encoding is specified in the setData() method.

Name

public java.lang.String Name
Name of the part. Optional.

FileName

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

rawHDR

public java.lang.String rawHDR
header of the part as sent or received.

partCounter

public int partCounter
number of subparts in the part (if ContentType is "Multipart").

boundary

public java.lang.String boundary
boundary used to separate subparts. Calculated by the system.
Constructor Detail

MailMsgPart

public MailMsgPart()
Method Detail

getPart

public MailMsgPart getPart(int num)
returns a subparft of the part.

addPart

public void addPart(MailMsgPart p)
Adds a subpart to the part. The ContentType will then be multipart.

setBinaryData

public void setBinaryData(byte[] b)
sets the binary content of the part. The part will be encoded with BASE64.

setData

public void setData(java.lang.String d,
                    int encoding)
sets the content of the part if not binary, you must specify an encoding method:

getData

public java.lang.String getData()
returns the non-binary content. Call this when the part is not encoded with BASE64.

getBinaryData

public byte[] getBinaryData()
returns binary content of the file. Call this when you receive a mail coded with BASE64.

setCodedData

public void setCodedData(java.lang.String d)
method called by the POP connection to store the received data.

saveToFile

public boolean saveToFile(java.lang.String psFile)
saves the content of the part to a file. Returns true on success.

getHeader

public java.lang.String getHeader()
returns the header of the part in rfc822 format.