研究了一下,发现getUnreadMessageCount每次都是计算所有邮件,getNewMessageCount总是0,在网上看到使用
inbox.addMessageCountListener(new MessageCountListener(){}
这个有怎么用呢,
如果直接写一个监听器该怎样写呢?谢谢了

解决方案 »

  1.   


    folder = store.getDefaultFolder();//获取默认文件夹
                
                if (folder == null) throw new Exception("No default folder");
                
                folder = folder.getFolder("INBOX");//链接收件箱
                
                if (folder == null) throw new Exception("No POP3 INBOX");
                
                folder.open(Folder.READ_ONLY);//使用只读方式打开收件箱
                
                Message[] msgs = folder.getMessages();//得到文件夹信息,获取邮件列表这个得到的应该是新邮件,然后定时接收就可以了,
      

  2.   

    javamail是消息驱动的,并发效率高,但是很难得到发送邮件的实时信息,所以我通过轮询来实现。发出去一封,反复查询收件箱,直到查到为止。
      

  3.   

    现在我开了一个线程每隔一段时间来扫描一次是否有邮件到,这是现在没扫描一次出现javax.mail.AuthenticationFailedException: maildir in use 的问题,请问这个maildir in use 是什么意思?
      

  4.   

    上面出现javax.mail.AuthenticationFailedException: maildir in use 的原因是没有关闭folder和store,
      

  5.   

    改为sina邮箱后,又出现以下错误:
    javax.mail.MessagingException: Connect failed;
      nested exception is:
    java.net.SocketException: Socket is not connected: connect
    at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:120)
    at javax.mail.Service.connect(Service.java:233)
    at javax.mail.Service.connect(Service.java:134)搞不懂了,写一个收邮件的程序怎么就这么困难呢
      

  6.   

    http://topic.csdn.net/u/20080614/18/da122169-3402-4977-b6df-f1330f5b7b55.html看看我写的.  我的是内网.你把验证换成外网试试