Hi, I have problems with differents MSG files. I open a file MSG with Oulook 2010 (32bit) and I can not read the body because the Outlook do not detect the content of the body. But I know that the MSG file has a body and I can read the body when I open the body with the Internet Explorer. It can make so: Actions-->View in the Browser Then, the POI library can neither processed the body from the MSG file. Can anybody help me? Thanks, Warmest regards. Werner
Can you please upload a problematic file, and ideally a testcase that shows what you're trying to do with POI and what isn't working?
Created attachment 29494 [details] This is a MSG file example
Firstly, thanks for your answer. Ok, I have uploaded a example file. Regards
Hi, I use the following code to get a embedded MSG file: MAPIMessage msg = new MAPIMessage(INPUTFILE); AttachmentChunks[] attachments = msg.getAttachmentFiles(); for(AttachmentChunks attachment : attachments) { DirectoryChunk chunkDirectory = attachment.attachmentDirectory; MAPIMessage attachmentMSG = chunkDirectory.getAsEmbededMessage();
Hi, I use the following code to get a embedded MSG file: MAPIMessage msg = new MAPIMessage(INPUTFILE); AttachmentChunks[] attachments = msg.getAttachmentFiles(); for(AttachmentChunks attachment : attachments) { DirectoryChunk chunkDirectory = attachment.attachmentDirectory; MAPIMessage attachmentMSG = chunkDirectory.getAsEmbededMessage(); String body = attachmentMSG.getTextBody(); } The body is null because the library can not detect the content of the body and Outlook 2010 neither. But it can read the body with the Internet Explorer.
Created attachment 34595 [details] unit test You got a ChunkNotFoundException when calling getTextBody() because the message had an Html body instead of a plain text body. Only one body type (plain text, html, rtf) can be saved in a message. This is the error that you would get if you checked getTextBody() on a message containing an html body. Chunk not found org.apache.poi.hsmf.exceptions.ChunkNotFoundException: Chunk not found at org.apache.poi.hsmf.MAPIMessage.getStringFromChunk(MAPIMessage.java:181) at org.apache.poi.hsmf.MAPIMessage.getTextBody(MAPIMessage.java:194) at org.apache.poi.hsmf.TestFileWithAttachmentsRead.test54021_read_text_body(TestFileWithAttachmentsRead.java:190)
(In reply to Javen O'Neal from comment #6) > Only one body type (plain text, html, rtf) can be saved in a message. It appears that this is a false statement. A message can contain more than one body type, as indicated in test-data/hpsf/outlook_30_msg.msg from scratchpad/testcases/o.a.p.hpsf.TestBasics#testBody [1] in r1777463. However, a message is not required to store a plain text chunk. It's up to the mail client to figure out how to display a message by rendering the HTML or RTF if a text version is not present (plain text seems like a fallback anyways). [1] http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/TestBasics.java?r1=1777463&r2=1777462&pathrev=1777463