Question

Using mstor w/ Windows, I am able to connect to mbox stores (thanks to SO). And it would seem that I can read message pointers; I know this because whenever I iterate over the store, it iterates over the right number of messages. The problem is that no headers nor content is loading! Any idea?

Yes, I have the JavaMail stuff in the classpath (it comes in mstor's lib these days). And I'm even using it on one of mstor's sample files (imagined.mbox).

Thanks in advance.

My code:

public static void main(String[] args) throws Exception {

  Properties props = new Properties();
  props.setProperty("mstor.mbox.metadataStrategy", "xml");
  Session session1 = Session.getDefaultInstance(props);

  Session session = Session.getDefaultInstance(new Properties());

  Store store = session.getStore(new URLName("mstor:C:/tmp/imagined.mbox"));
  store.connect();

  System.out.println(store.isConnected());

  Folder inbox = store.getDefaultFolder();  // no subfolder here; even if there is an Inbox, I get the same thing...
  inbox.open(Folder.READ_ONLY);

  Message[] messages = inbox.getMessages();
  for (Message m : messages) {
    System.out.println(m.getSubject());
  }

}

My typical result:

true (i.e., yes, I'm connected...)
null
null
null
null

No correct solution

OTHER TIPS

I see this is a month old, but I just ran into the same issue. Try adding m.saveChanges() as the first line in your for loop. This forces mstor to create a cache of the message's headers.

Logically your code above is correct. It's odd that we had to add this line, but it's a functional work-around for our problem.

If you already found another solution, please don't forget to share. Just because nobody had an answer doesn't mean nobody had the same problem!

After creating an instance of Properties called properties, use the following to disable the cache:

properties.setProperty("mstor.mbox.metadataStrategy", "none");

If you do this and try again, you should find you're able to call the accessor methods for subject, from, to etc without having to resort to the m.saveChanges() hack.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top