public class OutlookMessageParser extends Object
It parses the .msg file and stores the information in a OutlookMessage object. Attachments are put into an OutlookFileAttachment object.
Hence, please keep in mind that the complete mail is held in the memory! If an attachment is another .msg file, this attachment is not processed as a normal
attachment but rather included as a OutlookMsgAttachment. This attached mail is, again, a OutlookMessage object and may have further
outlookAttachments and so on.
Furthermore there is a feature which allows us to extract HTML bodies when only RTF bodies are available. In order to achieve this a conversion class
implementing RTF2HTMLConverter is used. This can be overridden with a custom implementation as well (see code below for an example).
Note: this code has not been tested on a wide range of .msg files. Use in production level (as in any other level) at your own risk.
Usage:
OutlookMessageParser msgp = new OutlookMessageParser();
msgp.setRtf2htmlConverter(new SimpleRTF2HTMLConverter()); //optional (if you want to use
your own implementation)
OutlookMessage msg = msgp.parseMsg("test.msg");
| Constructor and Description |
|---|
OutlookMessageParser() |
| Modifier and Type | Method and Description |
|---|---|
OutlookMessage |
parseMsg(@NotNull File msgFile)
Parses a .msg file provided in the specified file.
|
OutlookMessage |
parseMsg(@NotNull InputStream msgFileInputStream)
Parses a .msg file provided by an input stream.
|
OutlookMessage |
parseMsg(@NotNull String msgFile)
Parses a .msg file provided in the specified file.
|
void |
setRtf2htmlConverter(org.bbottema.rtftohtml.RTF2HTMLConverter rtf2htmlConverter)
Setter for overriding the default
RTF2HTMLConverter
implementation which is used to get HTML code from an RTF body. |
public OutlookMessage parseMsg(@NotNull @NotNull File msgFile) throws IOException
msgFile - The .msg file.OutlookMessage object representing the .msg file.IOException - Thrown if the file could not be loaded or parsed.public OutlookMessage parseMsg(@NotNull @NotNull String msgFile) throws IOException
msgFile - The .msg file as a String path.OutlookMessage object representing the .msg file.IOException - Thrown if the file could not be loaded or parsed.public OutlookMessage parseMsg(@NotNull @NotNull InputStream msgFileInputStream) throws IOException
msgFileInputStream - The .msg file as a InputStream.OutlookMessage object representing the .msg file.IOException - Thrown if the file could not be loaded or parsed.public void setRtf2htmlConverter(org.bbottema.rtftohtml.RTF2HTMLConverter rtf2htmlConverter)
RTF2HTMLConverter
implementation which is used to get HTML code from an RTF body.rtf2htmlConverter - The converter instance to be used.Copyright © 2017–2022. All rights reserved.