public class MAPIMessage extends POIReadOnlyDocument
Modifier and Type | Class and Description |
---|---|
static class |
MAPIMessage.MESSAGE_CLASS
A MAPI file can be an email (NOTE) or a number of other types
|
Constructor and Description |
---|
MAPIMessage()
Constructor for creating new files.
|
MAPIMessage(DirectoryNode poifsDir)
Constructor for reading MSG Files from a certain
point within a POIFS filesystem
|
MAPIMessage(java.io.File file)
Constructor for reading MSG Files from the file system.
|
MAPIMessage(java.io.InputStream in)
Constructor for reading MSG Files from an input stream.
|
MAPIMessage(POIFSFileSystem fs)
Constructor for reading MSG Files from a POIFS filesystem
|
MAPIMessage(java.lang.String filename)
Constructor for reading MSG Files from the file system.
|
Modifier and Type | Method and Description |
---|---|
AttachmentChunks[] |
getAttachmentFiles()
Gets the message attachments.
|
java.lang.String |
getConversationTopic()
Gets the conversation topic of the parsed Outlook Message.
|
java.lang.String |
getDisplayBCC()
Gets the display value of the "BCC" line of the outlook message.
|
java.lang.String |
getDisplayCC()
Gets the display value of the "CC" line of the outlook message.
|
java.lang.String |
getDisplayFrom()
Gets the display value of the "FROM" line of the outlook message
This is not the actual address that was sent from but the formated display of the user name.
|
java.lang.String |
getDisplayTo()
Gets the display value of the "TO" line of the outlook message.
|
java.lang.String[] |
getHeaders()
Returns all the headers, one entry per line
|
java.lang.String |
getHtmlBody()
Gets the html body of this Outlook Message, if this email
contains a html version.
|
Chunks |
getMainChunks()
Gets the main, core details chunks
|
MAPIMessage.MESSAGE_CLASS |
getMessageClassEnum()
Gets the message class of the parsed Outlook Message.
|
java.util.Calendar |
getMessageDate()
Gets the date that the message was accepted by the
server on.
|
NameIdChunks |
getNameIdChunks()
Gets the Name ID chunks, or
null if there aren't any
|
RecipientChunks[] |
getRecipientDetailsChunks()
Gets all the recipient details chunks.
|
java.lang.String |
getRecipientEmailAddress()
Returns all the recipients' email address, separated by
semicolons.
|
java.lang.String[] |
getRecipientEmailAddressList()
Returns an array of all the recipient's email address, normally
in TO then CC then BCC order.
|
java.lang.String |
getRecipientNames()
Returns all the recipients' names, separated by
semicolons.
|
java.lang.String[] |
getRecipientNamesList()
Returns an array of all the recipient's names, normally
in TO then CC then BCC order.
|
java.lang.String |
getRtfBody()
Gets the RTF Rich Message body of this Outlook Message, if this email
contains a RTF (rich) version.
|
java.lang.String |
getStringFromChunk(StringChunk chunk)
Gets a string value based on the passed chunk.
|
java.lang.String |
getSubject()
Gets the subject line of the Outlook Message
|
java.lang.String |
getTextBody()
Gets the plain text body of this Outlook Message
|
void |
guess7BitEncoding()
Tries to identify the correct encoding for 7-bit (non-unicode)
strings in the file.
|
boolean |
has7BitEncodingStrings()
Does this file contain any strings that
are stored as 7 bit rather than unicode?
|
boolean |
isReturnNullOnMissingChunk()
Will you get a null on a missing chunk, or a
ChunkNotFoundException (default is the
exception). |
void |
set7BitEncoding(java.lang.String charset)
Many messages store their strings as unicode, which is
nice and easy.
|
void |
set7BitEncoding(java.lang.String generalcharset,
java.lang.String htmlbodycharset,
java.lang.String bodycharset) |
void |
setReturnNullOnMissingChunk(boolean returnNullOnMissingChunk)
Sets whether on asking for a missing chunk,
you get back null or a
ChunkNotFoundException
(default is the exception). |
write, write, write
clearDirectory, close, createInformationProperties, getDirectory, getDocumentSummaryInformation, getEncryptedPropertyStreamName, getEncryptionInfo, getPropertySet, getPropertySet, getSummaryInformation, initDirectory, readProperties, replaceDirectory, validateInPlaceWritePossible, writeProperties, writeProperties, writeProperties
public MAPIMessage()
public MAPIMessage(java.lang.String filename) throws java.io.IOException
filename
- Name of the file to readjava.io.IOException
- on errors reading, or invalid datapublic MAPIMessage(java.io.File file) throws java.io.IOException
file
- The file to read fromjava.io.IOException
- on errors reading, or invalid datapublic MAPIMessage(java.io.InputStream in) throws java.io.IOException
Note - this will buffer the whole message into memory
in order to process. For lower memory use, use MAPIMessage(File)
in
- The InputStream to buffer then read fromjava.io.IOException
- on errors reading, or invalid datapublic MAPIMessage(POIFSFileSystem fs) throws java.io.IOException
fs
- Open POIFS FileSystem containing the messagejava.io.IOException
- on errors reading, or invalid datapublic MAPIMessage(DirectoryNode poifsDir) throws java.io.IOException
poifsDir
- Directory containing the messagejava.io.IOException
- on errors reading, or invalid datapublic java.lang.String getStringFromChunk(StringChunk chunk) throws ChunkNotFoundException
ChunkNotFoundException
- if the chunk isn't therepublic java.lang.String getTextBody() throws ChunkNotFoundException
ChunkNotFoundException
- If the text-body chunk does not exist and
returnNullOnMissingChunk is setpublic java.lang.String getHtmlBody() throws ChunkNotFoundException
ChunkNotFoundException
- If the html-body chunk does not exist and
returnNullOnMissingChunk is setpublic java.lang.String getRtfBody() throws ChunkNotFoundException
ChunkNotFoundException
- If the rtf-body chunk does not exist and
returnNullOnMissingChunk is setpublic java.lang.String getSubject() throws ChunkNotFoundException
ChunkNotFoundException
- If the subject-chunk does not exist and
returnNullOnMissingChunk is setpublic java.lang.String getDisplayFrom() throws ChunkNotFoundException
ChunkNotFoundException
- If the from-chunk does not exist and
returnNullOnMissingChunk is setpublic java.lang.String getDisplayTo() throws ChunkNotFoundException
RecipientChunks
.ChunkNotFoundException
- If the to-chunk does not exist and
returnNullOnMissingChunk is setpublic java.lang.String getDisplayCC() throws ChunkNotFoundException
RecipientChunks
.ChunkNotFoundException
- If the cc-chunk does not exist and
returnNullOnMissingChunk is setpublic java.lang.String getDisplayBCC() throws ChunkNotFoundException
RecipientChunks
.
This will only be present in sent emails, not received ones!ChunkNotFoundException
- If the bcc-chunk does not exist and
returnNullOnMissingChunk is setpublic java.lang.String getRecipientEmailAddress() throws ChunkNotFoundException
ChunkNotFoundException
public java.lang.String[] getRecipientEmailAddressList() throws ChunkNotFoundException
ChunkNotFoundException
public java.lang.String getRecipientNames() throws ChunkNotFoundException
getDisplayTo()
, getDisplayCC()
and getDisplayBCC()
.ChunkNotFoundException
public java.lang.String[] getRecipientNamesList() throws ChunkNotFoundException
getDisplayTo()
, getDisplayCC()
and getDisplayBCC()
.ChunkNotFoundException
public void guess7BitEncoding()
Many messages store their strings as unicode, which is nice and easy. Some use one-byte encodings for their strings, but don't always store the encoding anywhere helpful in the file.
This method checks for codepage properties, and failing that looks at the headers for the message, and uses these to guess the correct encoding for your file.
Bug #49441 has more on why this is needed
public void set7BitEncoding(java.lang.String charset)
guess7BitEncoding()
public void set7BitEncoding(java.lang.String generalcharset, java.lang.String htmlbodycharset, java.lang.String bodycharset)
public boolean has7BitEncodingStrings()
public java.lang.String[] getHeaders() throws ChunkNotFoundException
ChunkNotFoundException
public java.lang.String getConversationTopic() throws ChunkNotFoundException
ChunkNotFoundException
- If the conversation-topic chunk does not exist and
returnNullOnMissingChunk is setpublic MAPIMessage.MESSAGE_CLASS getMessageClassEnum() throws ChunkNotFoundException
ChunkNotFoundException
- If the message-class chunk does not exist and
returnNullOnMissingChunk is setpublic java.util.Calendar getMessageDate() throws ChunkNotFoundException
ChunkNotFoundException
public Chunks getMainChunks()
public RecipientChunks[] getRecipientDetailsChunks()
getDisplayTo()
* CC recipients, in the order returned by getDisplayCC()
* BCC recipients, in the order returned by getDisplayBCC()
public NameIdChunks getNameIdChunks()
public AttachmentChunks[] getAttachmentFiles()
public boolean isReturnNullOnMissingChunk()
ChunkNotFoundException
(default is the
exception).public void setReturnNullOnMissingChunk(boolean returnNullOnMissingChunk)
ChunkNotFoundException
(default is the exception).Copyright 2020 The Apache Software Foundation or its licensors, as applicable.