https://bz.apache.org/bugzilla/show_bug.cgi?id=59786
Sebb <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEEDINFO |NEW --- Comment #7 from Sebb <[email protected]> --- [It's a bit of a pain building POI, because compile-ooxml-lite unexpectedly runs loads of tests which don't always work for me, and even if they do, they take a long time and produce lots of output] I have now got "ant jar" to complete after commenting out the target compile-ooxml-lite. However it does not extract any body text; I get: Extracting... No message body found, POI/message.rtf not created Extraction completed A bit of experimentation shows that the new attribute has to be defined as a new entry in MAPIProperty.java; if this is done it is then picked up by the dumper as well. Using MAPIProperty.createCustom locally does not work; the method getMessageMAPIAttribute returns null. There's another change that needs to be done: if the body is an instance of MAPIStringAttribute (as here) then writing the byte data directly to the file produces an unreadable file which appears to be in UTF-16LE (no BOM). Here's a very crude patch that works for me: ### Eclipse Workspace Patch 1.0 #P ApachePOI Index: src/scratchpad/src/org/apache/poi/hmef/extractor/HMEFContentsExtractor.java =================================================================== --- src/scratchpad/src/org/apache/poi/hmef/extractor/HMEFContentsExtractor.java (revision 1751374) +++ src/scratchpad/src/org/apache/poi/hmef/extractor/HMEFContentsExtractor.java (working copy) @@ -95,7 +95,12 @@ OutputStream fout = new FileOutputStream(dest); try { - fout.write(body.getData()); + if (body instanceof MAPIStringAttribute) { + fout.write(((MAPIStringAttribute) body).getDataString().getBytes()); // TODO fix the output charset + } else { + fout.write(body.getData()); + } } finally { fout.close(); } @@ -104,13 +109,7 @@ protected MAPIAttribute getBodyAttribute() { MAPIAttribute body = message.getMessageMAPIAttribute(MAPIProperty.RTF_COMPRESSED); if (body != null) return body; - - // See bug #59786 - we'd really like a test file to confirm if this - // is the right properties + if this is truely general or not! - MAPIProperty uncompressedBody = - MAPIProperty.createCustom(0x3fd9, Types.ASCII_STRING, "Uncompressed Body"); - // Return this uncompressed one, or null if that isn't their either - return message.getMessageMAPIAttribute(uncompressedBody); + return message.getMessageMAPIAttribute(MAPIProperty.WINMAILNEW); } /** Where the following was added to MAPIProperty.java: public static final MAPIProperty WINMAILNEW = // TODO fix the names! new MAPIProperty(0x3fd9, Types.UNICODE_STRING, "Uncompressed Body","WINMAILNEW"); -- You are receiving this mail because: You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
