我按照说明使用下面的代码打开一个邮件存储,并且它工作正常,花了几秒钟来解码我的eml,但是然后我没有文件夹,也没有消息。没有例外的想法。该怎么办?
Store store = session.getStore(new URLName("mstor:test-data/01-one-time-test/215.eml"));
store.connect();
// read messages from Inbox..
Folder inbox = store.getDefaultFolder();
inbox.open(Folder.READ_ONLY);
Folder [] folders = inbox.list();
System.out.println("folder count: " + folders.length);
Message[] messages = inbox.getMessages();
System.out.println("message count: " + messages.length);
=================================================== ===
我解决了:
您需要向mstor提供一个包含mbox文件的文件夹。然后,mstor可以很好地工作。关于它的好处是有一个Maven下载。
再见!
最佳答案
Properties properties = new Properties();
this.properties.setProperty("mail.store.protocol", "mstor");
this.properties.setProperty("mstor.mbox.metadataStrategy", "none");
this.properties.setProperty("mstor.mbox.cacheBuffers", "disabled");
this.properties.setProperty("mstor.mbox.bufferStrategy", "mapped");
this.properties.setProperty("mstor.metadata", "disabled");
this.properties.setProperty("mstor.mozillaCompatibility", "enbled");
this.session = Session.getInstance(this.properties);
try {
final Store store = session.getStore(new URLName("mstor:" + path));
try {
store.connect();
this.inbox = (MStorFolder) store.getFolder(path);//getDefaultFolder();//.getFolder(path);
this.inbox.open(Folder.READ_ONLY);
count =inbox.getMessageCount();
} catch (MessagingException ex) {
ex.printStackTrace();
}
} catch (NoSuchProviderException e) {
e.printStackTrace();
}