Outlook javamail error "A3 BAD User is authenticated but not connected"

时间:2019-03-06 11:31:26

标签: java outlook javamail

i try to open folder in my email but no luck.

this is the error:

Mar 06, 2019 1:24:14 PM Export run
SEVERE: A3 BAD User is authenticated but not connected.
javax.mail.MessagingException: A3 BAD User is authenticated but not connected.;
  nested exception is:
    com.sun.mail.iap.BadCommandException: A3 BAD User is authenticated but not connected.
    at com.sun.mail.imap.IMAPFolder.open(IMAPFolder.java:960)
    at Export.getEmails(Export.java:115)
    at Export.run(Export.java:72)
    at Main.main(Main.java:5)
Caused by: com.sun.mail.iap.BadCommandException: A3 BAD User is authenticated but not connected.
    at com.sun.mail.iap.Protocol.handleResult(Protocol.java:338)
    at com.sun.mail.imap.protocol.IMAPProtocol.select(IMAPProtocol.java:656)
    at com.sun.mail.imap.IMAPFolder.open(IMAPFolder.java:926)
    ... 3 more

and this is what i am tried:

public void getEmails() throws MessagingException, IOException {
    Session session = Session.getInstance(props);
    session.setDebug(DEBUG);

    store = null;
    store = session.getStore("imap");

    store.connect("imap-mail.outlook.com", this.userName, this.password);
    folder = store.getFolder(FOLDER_NAME);
    folder.open(Folder.READ_ONLY);
    int total_messages = folder.getMessageCount();
    if(total_messages > 0) {
        messages = folder.getMessages();
    }
}

the is the props:

props = new Properties();        
props.setProperty("mail.store.protocol", "imap");
props.setProperty("mail.imap.ssl.enable", "true");  
props.setProperty("mail.imap.starttls.enable", "true");    
props.setProperty("mail.imap.host", "imap-mail.outlook.com");
props.setProperty("mail.imap.port", "993");   

the username and the password are ok. I tried to change the password and I got another error with authenticated so the password and the username are correct.

i check the store.isConnected and I got true. the problem in the line:

folder.open(Folder.READ_ONLY);

what can be the problem?

tnx a lot

1 个答案:

答案 0 :(得分:0)

我新创建的邮箱花了很长时间才能在O365上注册其所有配置,至少对我来说,这看起来像是计时问题,希望其他人觉得这有用。