com.mirrorworlds.lifestreams.mail.tnef
Class TnefMessage

java.lang.Object
  |
  +--com.mirrorworlds.lifestreams.mail.tnef.TnefMessage

public class TnefMessage
extends java.lang.Object

This class contains a Tnef Message decoded from a TNEF byte stream. Note that the TnefMessage class is not related to the Java Mail API's Message class. A TnefMessage class can contain one or more attachments.

Example:

       try {
          String filename = "winmail.dat";
          //create message object using default parser and builder.
          TnefMessage msg = JTnef.createTnefMessage(filename);          
          msg.printInfo(); // print debug info
          int count = msg.getCount();   // get number of attachments.   
           for (int i = 0; i < count; i++) { // loop thru attachments and print
              TnefAttachment a = msg.getAttachmentAt(i);
               System.out.println("   -- ");
               a.printInfo();
               // content-type of attachment is a.getContentType();
               // filename of attachment is a.getFilename();
               // attachment stream is a.getInputStream();
               // you can save attachment:
               //      File f = new File(a.getFilename);
               //      FileOutputStream fos = new FileOutputStream(f);      
               //      a.writeTo(f); // save attachment.
           }
       }catch(Exception e) {
           e.printStackTrace
       } 
 

Version:
Feb 20, 2000 Lifestreams 1.5

Constructor Summary
TnefMessage()
          Creates an empty TNEF message.
 
Method Summary
 void addAttachment(TnefAttachment attachment)
          Adds an attachment to this message.
 TnefAttachment getAttachmentAt(int index)
           
 java.lang.String getAttribute(java.lang.String name)
           
 java.lang.String getContentType()
           
 int getCount()
           
 int getKey()
           
 int getPriority()
           
 int getSignature()
           
 java.lang.String getText()
           
 int getTnefVersion()
           
 void printInfo()
          Prints debugging info.
 void setAttribute(java.lang.String name, java.lang.String value)
          Sets the message attributes such as subject, date-received etc.
 void setDate(java.util.Date d)
          Sets the date.
 void setKey(int key)
          Sets the TNEF message 16 bit key
 void setPriority(int prio)
          Sets the message priority.
 void setSignature(int signature)
          Sets the TNEF stream 32 bit signature.
 void setText(java.lang.String text)
          Sets the message body text.
 void setTnefVersion(int version)
          Sets the TNEF stream (32 bit) version.
 void writeToMIME(java.io.OutputStream out)
          Writes this message (and its attachments) as a MIME multipart/mixed message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TnefMessage

public TnefMessage()
Creates an empty TNEF message. The content type is defaulted to "message/tnef" (fictional content-type) and the date is set to the current time.
Method Detail

getCount

public int getCount()
Returns:
the number of attachment in this message.

getContentType

public java.lang.String getContentType()
Returns:
the MIME conent-type of this message.

getAttachmentAt

public TnefAttachment getAttachmentAt(int index)
                               throws java.lang.ArrayIndexOutOfBoundsException
Returns:
the message attachment at the given index.

getAttribute

public java.lang.String getAttribute(java.lang.String name)
Returns:
the attribute. eg: subject

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.String value)
Sets the message attributes such as subject, date-received etc.
Parameters:
name - attribute name
value - value of attribute.

setText

public void setText(java.lang.String text)
Sets the message body text. (ignored in this implementation).
Parameters:
text - message body

getText

public java.lang.String getText()
Returns:
message body text. (ignored in this implementation).

setSignature

public void setSignature(int signature)
Sets the TNEF stream 32 bit signature.

getSignature

public int getSignature()
Returns:
TNEF stream 32 bit signature.

setKey

public void setKey(int key)
Sets the TNEF message 16 bit key

getKey

public int getKey()
Returns:
TNEF Message 16 bit key.

setTnefVersion

public void setTnefVersion(int version)
Sets the TNEF stream (32 bit) version.

getTnefVersion

public int getTnefVersion()
Returns:
TNEF stream version.

setPriority

public void setPriority(int prio)
Sets the message priority. (1-3).

getPriority

public int getPriority()
Returns:
the message priority. (1-3).

addAttachment

public void addAttachment(TnefAttachment attachment)
Adds an attachment to this message.

setDate

public void setDate(java.util.Date d)
Sets the date. (same as 'date-sent').

writeToMIME

public void writeToMIME(java.io.OutputStream out)
                 throws java.io.IOException
Writes this message (and its attachments) as a MIME multipart/mixed message. (to convert tnef -> mime).

method not implemented. TBD.


printInfo

public void printInfo()
Prints debugging info.