使用此代码:
import java.io.*;
import java.util.*;
import javax.mail.*;
public class Mbox {
public static void main(String[] args) {
Properties properties = new Properties();
properties.setProperty("mail.store.protocol", "mstor");
properties.setProperty("mstor.mbox.metadataStrategy", "none");
properties.setProperty("mstor.mbox.cacheBuffers", "disabled");
properties.setProperty("mstor.cache.disabled", "true");
properties.setProperty("mstor.mbox.bufferStrategy", "mapped");
properties.setProperty("mstor.metadata", "disabled");
Session session = Session.getDefaultInstance(properties);
try {
Store store = session.getStore(new URLName("mstor:C:/INBOX"));
store.connect();
Folder inbox = store.getDefaultFolder().getFolder("inbox");
inbox.open(Folder.READ_ONLY);
Message m = inbox.getMessage(1);
} catch (Exception e) {
e.printStackTrace();
}
}
}
我正在尝试在java中设置mbox阅读程序。我在Linux和Windows上都试过了,但每次我在javax.mail.NoSuchProviderException: No provider for mstor
上获得异常session.getStore("mstor:C:/INBOX")
。我搜索了一会儿并制作了如上所示的属性文件,但仍然存在错误。
javax.mail.NoSuchProviderException: No provider for mstor
at javax.mail.Session.getProvider(Session.java:473)
at javax.mail.Session.getStore(Session.java:547)
at Mbox.main(Mbox.java:23)
我做错了什么?