0

Hi i am having problem with reading mails from manually created folder.

i can read mails from INBOX. but when i try to read mail from other than inbox it is giving error.

I hope stackoverflow will give solution. Thanks in advance...

Error Message:

Exception in thread "main" javax.mail.FolderNotFoundException: folder is not INBOX at com.sun.mail.pop3.POP3Folder.open(POP3Folder.java:183) at MailPop3.main(MailPop3.java:24)

My Code:

Properties properties = System.getProperties();
Session session = Session.getDefaultInstance(properties);
Store store = session.getStore("pop3");
store.connect(host, user, password);
Folder inbox = store.getFolder("MyPersonalFolder");
inbox.open(Folder.READ_ONLY);

// search for all "unseen" messages
Flags seen = new Flags(Flags.Flag.SEEN);
FlagTerm unseenFlagTerm = new FlagTerm(seen, false);
Message messages[] = inbox.search(unseenFlagTerm);
Raju RG
  • 1
  • 1
  • 1
    I think you will need to use IMAP rather than POP3 to access folders other than the inbox. Take a look at [this question](http://stackoverflow.com/questions/61176/getting-mail-from-gmail-into-java-application-using-imap) which is an example for Gmail and try the equivalent for Yahoo Mail. – mikej May 10 '12 at 07:51

2 Answers2

0

Hope you are using POP. By default POP points to INBOX only. As per POP3Folder,

A POP3 Folder (can only be "INBOX"). See the com.sun.mail.pop3 package documentation for further information on the POP3 protocol provider.

To access custom folders you require to use IMAPFolder.

Ravinder Reddy
  • 23,692
  • 6
  • 52
  • 82
0

This may sound weird, but I guess if you want to make your custome folder and use it in the code then you need to name it "Store", then it will work. Worked for me....took 3 hrs to research...hope works for you too

Gaurav Sachdeva
  • 652
  • 1
  • 10
  • 23