CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 1999
    Posts
    7

    JavaMail with Pop3

    I used JavaMail and Pop3 libraries from SUN to finish a simple project.
    But I met a problem.

    Session session = Session.getDefaultInstance(props, null);
    session.setDebug(true);
    Store store = null;
    Folder rf = null;
    store = session.getStore("pop3");
    host = "pop.mail.yahoo.com";
    user = "xxxx";
    password = "xxxx";
    store.connect(host, user, password);
    rf = store.getDefaultFolder();
    if (rf instanceof com.sun.mail.pop3.POP3Folder) {
    System.out.println("right");
    }
    System.out.println("\nOK. Folder got");

    Message[] msgs = rf.getMessages();
    System.out.println(msgs.length);




    The msgs.length == 0! , WHY? I used mail.yahoo.com to access, there are 7 mails in the INBOX folder.

    BTW , the "right" and "OK. Folder got" are printed.

    Could anyone help me out?
    Thanks




  2. #2
    Join Date
    Dec 1999
    Location
    Chonghe, Taipei County, Taiwan, R.O.C.
    Posts
    231

    Re: JavaMail with Pop3

    I think that it might be the problem that rf is the instance of POP3Folder but it does not
    mean that rf is the instance of Folder representing Inbox folder in the POP3 mail server.
    Hence, the number of message might be zero. Why do you use getFolder method with
    specifying the argument Inbox. You may reference the document of JavaMail API.
    good luck
    Alfred Wu


  3. #3
    Join Date
    Nov 1999
    Posts
    7

    Re: JavaMail with Pop3

    Thank you for your response.

    But I have tried to use getFolder("INBOX"),
    the msg.length == -1. Why?




  4. #4
    Join Date
    Dec 1999
    Location
    Chonghe, Taipei County, Taiwan, R.O.C.
    Posts
    231

    Re: JavaMail with Pop3

    add one instruction, rf.open(Folder.READ_WRITE), before calling rf.getMessages();
    and after instruction, store.getFolder(). I guess if it is the case that the folder is not
    opened.
    good luck


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured