2017-01-09 98 views
0

在此我試圖訪問使用IMAPS協議的郵箱。無法使用IMAPS協議訪問郵箱使用

public static void main(String[] args) throws MessagingException { 
    Properties props = new Properties(); 
    props.put("mail.store.protocol", "imaps"); 
    props.put("mail.imaps.port", "993"); 
    props.put("mail.imaps.starttls.enable", "true"); 
    Session session = Session.getDefaultInstance(props); 
    Store store = session.getStore("imaps"); 

    store.connect("imap-mail.outlook.com", "[email protected]","xxxx"); 
    Folder elisa = store.getFolder("Inbox"); 
    System.out.println("No of unread Mail " + elisa.getUnreadMessageCount()); 
} 

錯誤,我得到的是:

Exception in thread "main" javax.mail.AuthenticationFailedException: [AUTHENTICATIONFAILED] Invalid username or password. 
    at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:665) 
    at javax.mail.Service.connect(Service.java:295) 
    at javax.mail.Service.connect(Service.java:176) 
    at sid.test.email.EmailMain.main(EmailMain.java:21) 
+0

請以更好的方式問[如何問](http://stackoverflow.com/help/how-to-ask)。 添加一個問題和一個錯誤(如果存在)。 – GAlexMES

+0

對不起。但你知道答案嗎? –

+0

我應該如何知道你從未問過的問題的答案? 你有什麼樣的問題? 「不能」不是真正有用的。 – GAlexMES

回答

相關問題