当尝试使用JavaMail拉动POP3收件箱文件夹时,我没有收到任何电子邮件 [英] When attempting to pull POP3 inbox folder using JavaMail I am getting no emails

查看:96
本文介绍了当尝试使用JavaMail拉动POP3收件箱文件夹时,我没有收到任何电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如标题所示,我没有使用getFolder(INBOX)的消息;



昨天工作,我不认为我现在在调试时改变了任何东西我可以看到我没有消息。

  public String [] [] fetchEmails()throws异常{

String [] [] emailArray;

属性props = new Properties();

会话session = Session.getDefaultInstance(props,null);

Store store = session.getStore(pop3s);

store.connect(pop.gmail.com,******@googlemail.com,********);

文件夹文件夹= store.getFolder(INBOX);

folder.open(Folder.READ_ONLY);

int howmuch = folder.getMessageCount();
消息消息[] = folder.getMessages(); // int = 0,显示出错了,消息是空数组*

...... 。

folder.close(false);
store.close();

return emailArray;
}

任何事情都可以帮助,但一直驱使我疯了!

解决方案

一旦使用pop协议读取邮件,他们下载到客户端,并在pop服务器中删除一次以下语句
store.close()执行。
所以当你再次运行程序时,只会收到新的邮件(即那些以前没有通过任何流行客户端提取的邮件)



另见:
http://en.wikipedia.org/wiki/Post_Office_Protocol#Overview


As the title says I am getting no messages using getFolder("INBOX");

It was working yesterday, I do not think I changed anything now when debugging I can see that I am getting no messages.

 public String[][] fetchEmails() throws Exception {

        String[][] emailArray;

        Properties props = new Properties();

        Session session = Session.getDefaultInstance(props, null);

        Store store = session.getStore("pop3s");

        store.connect("pop.gmail.com", "******@googlemail.com", "********");

        Folder folder = store.getFolder("INBOX");

        folder.open(Folder.READ_ONLY);

        int howmuch = folder.getMessageCount();
        Message message[] = folder.getMessages();//The int = 0, which shows something has gone wrong, message is an empty array.*

        .......

        folder.close(false);
        store.close();

    return emailArray;
}

Anything could help, but it has been driving me insane!

解决方案

Once a mail read using pop protocol they downloaded to client and they get deleted in pop server once this below statement store.close() executes. So when you run the program again only the new mails are fetched(i.e., those mails which are not fetched previously through any pop client)

see also: http://en.wikipedia.org/wiki/Post_Office_Protocol#Overview

这篇关于当尝试使用JavaMail拉动POP3收件箱文件夹时,我没有收到任何电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆