如何使用mstor阅读mbox电子邮件

时间:2011-10-10 09:02:17

标签: java email mbox mstor

我正在使用mstor来读取mbox电子邮件消息,但是我无法使用我传递的urlName名称连接到商店,默认情况下它连接到其他 在我的macbine上的位置。我是否需要在继续连接到商店之前使用mstor JCR创建商店?

    Session session = Session.getDefaultInstance(new Properties());
    Store  store = session.getStore(new URLName("mstor:C:/mailbox/MyStore/Inbox"));
    store.connect();
    Folder inbox = store.getDefaultFolder().getFolder("inbox");
    inbox.open(Folder.READ_ONLY);               
    Message m = inbox.getMessage(0);

任何建议都有帮助

提前致谢..

1 个答案:

答案 0 :(得分:3)

//Set the Properties as shown below:



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.cache.disabled", "true");
            this.properties.setProperty("mstor.mbox.bufferStrategy", "mapped");
            this.properties.setProperty("mstor.metadata", "disabled");


//Also mstor count for messages start from 1 and not 0. so change it to 1.


Store  store = session.getStore(new URLName("mstor:C:/mailbox/MyStore/Inbox"));

    store.connect();

    Folder inbox = store.getDefaultFolder().getFolder("inbox");
    inbox.open(Folder.READ_ONLY);               
    Message m = inbox.getMessage(1);