|
-
March 5th, 2000, 01:32 AM
#1
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
-
March 5th, 2000, 04:45 AM
#2
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
-
March 5th, 2000, 07:50 PM
#3
Re: JavaMail with Pop3
Thank you for your response.
But I have tried to use getFolder("INBOX"),
the msg.length == -1. Why?
-
March 5th, 2000, 09:54 PM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|