Is it possible to cast javax.mail.Folder
to IMAPFolder
?
When casting in Netbeans, there was no error. Until the next line where I tried to open the folder
IMAPFolder ff = (IMAPFolder) store.getDefaultFolder();
ff.open(Folder.READ_WRITE);
I get BAD folder name on the logs:
[Thread-4] ERROR com.mansueli.mailtester.IMAPController - ERRORjavax.mail.MessagingException: A11 BAD [CLIENTBUG] SELECT Bad folder name. sc=Ttg5C13MBa61_091355_17p; nested exception is: com.sun.mail.iap.BadCommandException: A11 BAD [CLIENTBUG] SELECT Bad folder name. sc=Ttg5C13MBa61_091355_17p [JavaFX Application Thread] ERROR com.mansueli.mailtester.IMAPController - ERROR it wasn't possible to connect with IMAP properly ERRORjavax.mail.MessagingException: A11 BAD [CLIENTBUG] SELECT Bad folder name. sc=Ttg5C13MBa61_091355_17p; nested exception is: com.sun.mail.iap.BadCommandException: A11 BAD [CLIENTBUG] SELECT Bad folder name. sc=Ttg5C13MBa61_091355_17p A11 BAD [CLIENTBUG] SELECT Bad folder name. sc=Ttg5C13MBa61_091355_17p
I want to open it as an IMAP folder but only have the store.
Store store = session.getStore(imapstore);
The defaultFolder()
is not yet the inbox.
Try this instead::
IMAPFolder ff = (IMAPFolder) store.getDefaultFolder().getFolder("inbox");
ff.open(Folder.READ_WRITE);
Good Luck!