java mstor正在读取mbox文件,但返回null
使用mstor w/Windows,我能够连接到mbox商店(感谢SO)。我似乎可以阅读信息指针;我知道这一点,因为每当我迭代商店时,它都会迭代正确数量的消息。问题是没有加载标题或内容!知道吗
是的,我在类路径中有JavaMail的东西(现在它出现在mstor的库中)。我甚至还在mstor的一个示例文件(imagined.mbox)上使用它
提前谢谢
我的代码:
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());
}
}
我的典型结果是:
true (i.e., yes, I'm connected...)
null
null
null
null
# 1 楼答案
我知道这是一个月前的事了,但我遇到了同样的问题。尝试添加
m.saveChanges()
作为for循环的第一行。这将迫使mstor创建消息头的缓存从逻辑上讲,上面的代码是正确的。奇怪的是,我们不得不添加这一行,但这是解决我们问题的功能性解决方案
如果你已经找到了另一个解决方案,请不要忘记分享。仅仅因为没有人有答案并不意味着没有人有同样的问题