Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29934

Imap folder shared mailbox - BAD Command received in Invalid state

$
0
0

Using JavaMail i have problems updating an imap folder of a shared mailbox or just listing all folders of the shared mailbox.
(Updating folder of main account is no problem)

Mail provider is: office365

final Properties props = new Properties();
props.put("mail.imap.starttls.enable", true);
props.put("mail.imap.auth", true);
props.put("mail.imap.ssl.trust", "*");
props.put("mail.imap.ssl.enable", true);
props.put("mail.imap.auth.plain.disable", true);
props.put("mail.imap.auth.ntlm.disable", true);
props.put("mail.imap.auth.gssapi.disable", true);

final Session mailSession = javax.mail.Session.getInstance(props);
mailSession.setDebug(true);

final Store store = mailSession.getStore("imap");

store.connect("outlook.office365.com", 993, "user@domainname.de/Info", "******");
// A1 LOGIN user@domainname.de/Info ******
// A1 OK LOGIN completed.
// A2 CAPABILITY
// * CAPABILITY IMAP4 IMAP4rev1 AUTH=PLAIN UIDPLUS CHILDREN IDLE NAMESPACE LITERAL+
// A2 OK CAPABILITY completed.
// DEBUG IMAP: AUTH: PLAIN

A: Get List of folders

final Folder[] f = store.getDefaultFolder().list(); // list() throws exception
// A3 LIST """%"
// BAD Command received in Invalid state.

B: Update particular folder

final Folder folderSentItems = store.getFolder("Sent Items");
folderSentItems.open(Folder.READ_WRITE); // throws exception
// BAD Command received in Invalid state.
message.setFlag(Flag.SEEN, true);
folderSentItems.appendMessages(new Message[]
{
    message
});
store.close();

Wether I retrieve all folders a) or update any folder B, I get this exception:

Caused by: com.sun.mail.iap.BadCommandException: BAD Command received in Invalid state.

What is the problem?


Viewing all articles
Browse latest Browse all 29934

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>