3

I want to view other folders in my hotmail account, besides the Inbox.

String host = "pop3.live.com";
String username = "peepants@hotmail.com";
String password = "peepantspants";
Properties pop3Props = new Properties();
pop3Props.setProperty("mail.pop3s.port",  "995");
Session session = Session.getInstance(pop3Props, null);
Store store = session.getStore("pop3s");
store.connect(host, 995, username, password);

Folder folder = store.getFolder("INBOX");    //this works fine
folder.open(Folder.READ_WRITE);

Folder[] f = store.getDefaultFolder().list("*");
for (int i = 0; i < f.length; i++ )
    System.out.println( f[i].getFullName() );    //this only prints INBOX

Folder ofolder = store.getFolder("MyOtherFolder");    //this doesn't work
ofolder.open(Folder.READ_WRITE);

Message messages[] = folder.getMessages(); 
folder.copyMessages(new Message[]{messages[0]}, ofolder);    //this doesn't work

I cannot get into any other folder, besides Inbox.

store.getFolder("MyOtherFolder")

throws the following error

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

1 Answers1

1

You can't. The POP3 protocol only supports a single mailbox. As far as I know, Hotmail still doesn't support any other standard protocols such as IMAP that would allow access to other mailboxes.

Bill Shannon
  • 29,579
  • 6
  • 38
  • 40