com.auxilii.msgparser
Class Message

Object
  extended by com.auxilii.msgparser.Message

public class Message
extends Object

Class that represents a .msg file. Some fields from the .msg file are stored in special parameters (e.g., fromEmail). Attachments are stored in the property attachments). An attachment may be of the type MsgAttachment which represents another attached (encapsulated) .msg object.

Author:
roman.kurmanowytsch

Field Summary
protected  List<Attachment> attachments
          A list of all attachments (both FileAttachment and MsgAttachment).
protected  String bodyHTML
          The body in HTML format (if available)
protected  String bodyRTF
          The body in RTF format (if available)
protected  String bodyText
          The normalized body text.
protected  Date clientSubmitTime
          Client Submit Time
protected  String convertedBodyHTML
          The body in HTML format (converted from RTF)
protected  Date creationDate
           
protected  Date date
          Email Date
protected  String displayBcc
          The displayed Bcc: field
protected  String displayCc
          The displayed Cc: field
protected  String displayTo
          The displayed To: field
protected  String fromEmail
          The address part of From: mail address.
protected  String fromName
          The name part of the From: mail address
protected  String headers
          Email headers (if available)
protected  Date lastModificationDate
           
protected static Logger logger
           
protected  String messageClass
          The message class as defined in the .msg file.
protected  String messageId
          The message Id.
protected  Map<Integer,Object> properties
          Contains all properties that are not covered by the special properties.
protected  List<RecipientEntry> recipients
          A list containing all recipients for this message (which can be set in the 'to:', 'cc:' and 'bcc:' field, respectively).
protected  RTF2HTMLConverter rtf2htmlConverter
           
protected  String subject
          The mail's subject.
protected  String toEmail
          The address part of To: mail address.
protected  String toName
          The name part of the To: mail address
 
Constructor Summary
Message()
           
Message(RTF2HTMLConverter rtf2htmlConverter)
           
 
Method Summary
 void addAttachment(Attachment attachment)
           
 void addRecipient(RecipientEntry recipient)
           
protected  void checkToRecipient()
          Checks if the correct recipient's addresses are set.
 String convertToHex(Integer propCode)
          Converts a given integer to hex notation without leading '0x'.
protected  String convertValueToString(Object value)
           
 String createMailString(String mail, String name)
          Convenience method for creating an email address expression (including the name, the address, or both).
protected  byte[] decompressRtfBytes(byte[] value)
          Decompresses compressed RTF data.
 List<Attachment> getAttachments()
           
 List<RecipientEntry> getBccRecipients()
          Retrieves a list of RecipientEntry objects that represent the BCC recipients of the message.
 String getBodyHTML()
           
 String getBodyRTF()
           
 String getBodyText()
           
 List<RecipientEntry> getCcRecipients()
          Retrieves a list of RecipientEntry objects that represent the CC recipients of the message.
 Date getClientSubmitTime()
           
 String getConvertedBodyHTML()
           
 Date getCreationDate()
           
 Date getDate()
           
static Date getDateFromHeaders(String headers)
          Parses the message date from the mail headers.
 String getDisplayBcc()
           
 String getDisplayCc()
           
 String getDisplayTo()
           
 String getFromEmail()
           
protected static String getFromEmailFromHeaders(String headers)
          Parses the sender's email address from the mail headers.
 String getFromName()
           
 String getHeaders()
           
 Date getLastModificationDate()
           
 String getMessageClass()
           
 String getMessageId()
           
 Set<String> getProperties()
          Deprecated. 
 Set<String> getPropertiesAsHex()
          This method provides a convenient way of retrieving property keys for all guys that like to stick to hex values.
 Object getProperty(String name)
          Deprecated. 
 Set<Integer> getPropertyCodes()
          This method returns a list of all available properties.
 Object getPropertyFromHex(String name)
          This method provides a convenient way of retrieving properties for all guys that like to stick to hex values.
 String getPropertyListing()
          Generates a string that can be used to debug the properties of the msg.
 Object getPropertyValue(Integer code)
          This method retrieves the value for a specific property.
 List<RecipientEntry> getRecipients()
           
 String getSubject()
           
 String getToEmail()
           
 String getToName()
           
 RecipientEntry getToRecipient()
          Retrieves the RecipientEntry object that represents the TO recipient of the message.
protected static Date parseDateString(String date)
           
 void setAttachments(List<Attachment> attachments)
           
 void setBodyHTML(String bodyHTML)
           
protected  void setBodyHTML(String bodyToSet, boolean force)
           
 void setBodyRTF(Object bodyRTF)
           
 void setBodyText(String bodyText)
           
 void setClientSubmitTime(String value)
           
 void setConvertedBodyHTML(String convertedBodyHTML)
           
 void setCreationDate(String value)
           
 void setDate(Date date)
           
 void setDisplayBcc(String displayBcc)
           
 void setDisplayCc(String displayCc)
           
 void setDisplayTo(String displayTo)
           
 void setFromEmail(String fromEmail)
           
 void setFromEmail(String fromEmail, boolean force)
           
 void setFromName(String fromName)
           
 void setHeaders(String headers)
           
 void setLastModificationDate(String value)
           
 void setMessageClass(String messageClass)
           
 void setMessageId(String messageId)
           
 void setProperty(MessageProperty msgProp)
          Sets the name/value pair in the properties map.
 void setRecipients(List<RecipientEntry> recipients)
           
 void setSubject(String subject)
           
 void setToEmail(String toEmail)
           
 void setToEmail(String toEmail, boolean force)
           
 void setToName(String toName)
           
 String toLongString()
          Provides all information of this message object.
 String toString()
          Provides a short representation of this .msg object.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

protected static final Logger logger

messageClass

protected String messageClass
The message class as defined in the .msg file.


messageId

protected String messageId
The message Id.


fromEmail

protected String fromEmail
The address part of From: mail address.


fromName

protected String fromName
The name part of the From: mail address


toEmail

protected String toEmail
The address part of To: mail address.


toName

protected String toName
The name part of the To: mail address


subject

protected String subject
The mail's subject.


bodyText

protected String bodyText
The normalized body text.


displayTo

protected String displayTo
The displayed To: field


displayCc

protected String displayCc
The displayed Cc: field


displayBcc

protected String displayBcc
The displayed Bcc: field


bodyRTF

protected String bodyRTF
The body in RTF format (if available)


bodyHTML

protected String bodyHTML
The body in HTML format (if available)


convertedBodyHTML

protected String convertedBodyHTML
The body in HTML format (converted from RTF)


headers

protected String headers
Email headers (if available)


date

protected Date date
Email Date


clientSubmitTime

protected Date clientSubmitTime
Client Submit Time


creationDate

protected Date creationDate

lastModificationDate

protected Date lastModificationDate

attachments

protected List<Attachment> attachments
A list of all attachments (both FileAttachment and MsgAttachment).


properties

protected Map<Integer,Object> properties
Contains all properties that are not covered by the special properties.


recipients

protected List<RecipientEntry> recipients
A list containing all recipients for this message (which can be set in the 'to:', 'cc:' and 'bcc:' field, respectively).


rtf2htmlConverter

protected RTF2HTMLConverter rtf2htmlConverter
Constructor Detail

Message

public Message()

Message

public Message(RTF2HTMLConverter rtf2htmlConverter)
Method Detail

addAttachment

public void addAttachment(Attachment attachment)

addRecipient

public void addRecipient(RecipientEntry recipient)

setProperty

public void setProperty(MessageProperty msgProp)
                 throws ClassCastException
Sets the name/value pair in the properties map. Some properties are put into special attributes (e.g., toEmail when the property name is '0076').

Parameters:
name - The property name (i.e., the class of the document entry).
value - The value of the field.
Throws:
ClassCastException - Thrown if the detected data type does not match the expected data type.

convertValueToString

protected String convertValueToString(Object value)

checkToRecipient

protected void checkToRecipient()
Checks if the correct recipient's addresses are set.


parseDateString

protected static Date parseDateString(String date)
Parameters:
date - The date string to be converted (e.g.: 'Mon Jul 23 15:43:12 CEST 2012')
Returns:
A Date object representing the given date string.

decompressRtfBytes

protected byte[] decompressRtfBytes(byte[] value)
Decompresses compressed RTF data.

Parameters:
value - Data to be decompressed.
Returns:
A byte array representing the decompressed data.

toString

public String toString()
Provides a short representation of this .msg object.

Overrides:
toString in class Object
See Also:
Object.toString()

toLongString

public String toLongString()
Provides all information of this message object.

Returns:
The full message information.

createMailString

public String createMailString(String mail,
                               String name)
Convenience method for creating an email address expression (including the name, the address, or both).

Parameters:
mail - The mail address.
name - The name part of the address.
Returns:
A combination of the name and address.

getAttachments

public List<Attachment> getAttachments()
Returns:
the attachments

setAttachments

public void setAttachments(List<Attachment> attachments)
Parameters:
attachments - the attachments to set

getRecipients

public List<RecipientEntry> getRecipients()
Returns:
the recipients

setRecipients

public void setRecipients(List<RecipientEntry> recipients)
Parameters:
recipients - the recipients to set

getFromEmail

public String getFromEmail()
Returns:
the fromEmail

setFromEmail

public void setFromEmail(String fromEmail)
Parameters:
fromEmail - the fromEmail to set

setFromEmail

public void setFromEmail(String fromEmail,
                         boolean force)
Parameters:
fromEmail - the fromEmail to set
force - forces overwriting of the field if already set

getFromName

public String getFromName()
Returns:
the fromName

setFromName

public void setFromName(String fromName)
Parameters:
fromName - the fromName to set

getDisplayTo

public String getDisplayTo()

setDisplayTo

public void setDisplayTo(String displayTo)

getDisplayCc

public String getDisplayCc()

setDisplayCc

public void setDisplayCc(String displayCc)

getDisplayBcc

public String getDisplayBcc()

setDisplayBcc

public void setDisplayBcc(String displayBcc)

getMessageClass

public String getMessageClass()
Returns:
the messageClass

setMessageClass

public void setMessageClass(String messageClass)
Parameters:
messageClass - the messageClass to set

getMessageId

public String getMessageId()
Returns:
the messageId

setMessageId

public void setMessageId(String messageId)
Parameters:
messageId - the messageId to set

getSubject

public String getSubject()
Returns:
the subject

setSubject

public void setSubject(String subject)
Parameters:
subject - the subject to set

getToEmail

public String getToEmail()
Returns:
the toEmail

setToEmail

public void setToEmail(String toEmail)
Parameters:
toEmail - the toEmail to set

setToEmail

public void setToEmail(String toEmail,
                       boolean force)
Parameters:
toEmail - the toEmail to set
force - forces overwriting of the field if already set

getToName

public String getToName()
Returns:
the toName

setToName

public void setToName(String toName)
Parameters:
toName - the toName to set

getToRecipient

public RecipientEntry getToRecipient()
Retrieves the RecipientEntry object that represents the TO recipient of the message.

Returns:
the TO recipient of the message or null in case no RecipientEntry was found.

getCcRecipients

public List<RecipientEntry> getCcRecipients()
Retrieves a list of RecipientEntry objects that represent the CC recipients of the message.

Returns:
the CC recipients of the message.

getBccRecipients

public List<RecipientEntry> getBccRecipients()
Retrieves a list of RecipientEntry objects that represent the BCC recipients of the message.

Returns:
the BCC recipients of the message.

getBodyText

public String getBodyText()
Returns:
the bodyText

setBodyText

public void setBodyText(String bodyText)
Parameters:
bodyText - the bodyText to set

getBodyRTF

public String getBodyRTF()
Returns:
the bodyRTF

setBodyRTF

public void setBodyRTF(Object bodyRTF)
Parameters:
bodyRTF - the bodyRTF to set

getBodyHTML

public String getBodyHTML()
Returns:
the bodyHTML

setBodyHTML

public void setBodyHTML(String bodyHTML)
Parameters:
bodyHTML - the bodyHTML to set

getConvertedBodyHTML

public String getConvertedBodyHTML()
Returns:
the convertedBodyHTML which is basically the result of an RTF-HTML conversion

setConvertedBodyHTML

public void setConvertedBodyHTML(String convertedBodyHTML)
Parameters:
convertedBodyHTML - the bodyHTML to set

setBodyHTML

protected void setBodyHTML(String bodyToSet,
                           boolean force)
Parameters:
bodyHTML - the bodyHTML to set
force - forces overwriting of the field if already set

getHeaders

public String getHeaders()
Returns:
the headers

setHeaders

public void setHeaders(String headers)
Parameters:
headers - the headers to set

getFromEmailFromHeaders

protected static String getFromEmailFromHeaders(String headers)
Parses the sender's email address from the mail headers.

Parameters:
The - headers in a single String object
Returns:
The sender's email or null if nothing was found.

getDateFromHeaders

public static Date getDateFromHeaders(String headers)
Parses the message date from the mail headers.

Parameters:
headers - The headers in a single String object
Returns:
The Date object or null, if no valid Date: has been found

getDate

public Date getDate()
Returns:
the date

setDate

public void setDate(Date date)
Parameters:
date - the date to set

getClientSubmitTime

public Date getClientSubmitTime()

setClientSubmitTime

public void setClientSubmitTime(String value)

getCreationDate

public Date getCreationDate()

setCreationDate

public void setCreationDate(String value)

getLastModificationDate

public Date getLastModificationDate()

setLastModificationDate

public void setLastModificationDate(String value)

getProperties

@Deprecated
public Set<String> getProperties()
Deprecated. 

This method should no longer be used due to the fact that message properties are now stored with their keys being represented as integers.

Returns:
All available keys properties have been found for.

getPropertiesAsHex

public Set<String> getPropertiesAsHex()
This method provides a convenient way of retrieving property keys for all guys that like to stick to hex values.
Note that this method includes parsing of string values to integers which will be less efficient than using getPropertyCodes().

Returns:
All available keys properties have been found for.

getProperty

@Deprecated
public Object getProperty(String name)
Deprecated. 

This method should no longer be used due to the fact that message properties are now stored with their keys being represented as integers.

Please refer to getPropertyCodes() for dealing with integer based keys.

Returns:
The value for the requested property.

getPropertyFromHex

public Object getPropertyFromHex(String name)
This method provides a convenient way of retrieving properties for all guys that like to stick to hex values.
Note that this method includes parsing of string values to integers which will be less efficient than using getPropertyValue(Integer).

Parameters:
name - The hex notation of the property to be retrieved.
Returns:
The value for the requested property.

getPropertyCodes

public Set<Integer> getPropertyCodes()
This method returns a list of all available properties.

Returns:
All available keys properties have been found for.

getPropertyValue

public Object getPropertyValue(Integer code)
This method retrieves the value for a specific property.
Please refer to getPropertyValue(Integer) for dealing with integer based keys.
NOTE: You can also use fields defined within MAPIProp to easily read certain properties.

Parameters:
code - The key for the property to be retrieved.
Returns:
The value of the specified property.

getPropertyListing

public String getPropertyListing()
Generates a string that can be used to debug the properties of the msg.

Returns:
A property listing holding hexadecimal, decimal and string representations of properties and their values.

convertToHex

public String convertToHex(Integer propCode)
Converts a given integer to hex notation without leading '0x'.

Parameters:
propCode - The value to be formatted.
Returns:
A hex formatted number.


Copyright © 2007 Roman Kurmanowytsch