2

I am using apache's poi hsmf to process .msg outlook files.

When I try to retrieve date using MAPI's getdate function it throws a ChunkNotFound Exception, I do not know what is going wrong.

Here is the code snippet

MAPIMessage msg = new MAPIMessage("TestFolder/"+Filename);

  String Result = msg.getSubject(); // works

Calendar CaObj = msg.getMessageDate(); ->Throws a ChunkNotFoundException here

Any Ideas?

phntmasasin
  • 765
  • 1
  • 5
  • 14

1 Answers1

3

The ChunkNotFoundException is being thrown because there's no chunk in the file containing the message date

By default, MAPIMessage will thrown a ChunkNotFoundException when you ask for something that isn't there. If you want, you can change that so it returns Null instead. Just call setReturnNullOnMissingChunk(true) on it first, then you'll get nulls instead

Gagravarr
  • 47,320
  • 10
  • 111
  • 156
  • Thanks, But I need to retrieve those date time stamp.Don't all msg files have timestamps? Is there any other way to retrieve timestamps from these files? – phntmasasin Oct 06 '11 at 19:41
  • Only emails that have been sent will have a message submission timestamp, which is what getMessageDate returns. There may be other dates in a file that hasn't been sent, but you'd need to enumerate the chunks looking for one that's a date to find it – Gagravarr Oct 06 '11 at 21:18
  • 1
    It could be a bug, as reported here: https://bz.apache.org/bugzilla/show_bug.cgi?id=57744 Fixed in apache poi 3.11 – Neo Aug 13 '15 at 07:58
  • @Zardo fix-length properties still aren't quite handled correctly, see https://bz.apache.org/bugzilla/show_bug.cgi?id=53784 – Gagravarr Aug 13 '15 at 12:39