當我試圖訪問像無法訪問Outlook的共享郵箱與Java IMAPS
store.connect("imaps store address", 993, "[email protected]","PASSWORD");
我的郵箱,我可以能夠訪問郵箱。但是,當我試圖像以下:
store.connect("imaps store address", 993, "[email protected]/sharedmailbox_name","PASSWORD");
或
store.connect("imaps store address", 993, "[email protected]/[email protected]","PASSWORD");
我收到此錯誤:
Connecting to the IMAP server...javax.mail.AuthenticationFailedException: AUTHENTICATE failed. at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:725) at javax.mail.Service.connect(Service.java:366) at pkg.finale.test.CheckOutlook.initiate(CheckOutlook.java:38) at pkg.finale.test.CheckOutlook.main(CheckOutlook.java:17)
下面是代碼:
import java.util.Properties;
public class CheckOutlook {
public static void main(String[] args) {
initiate();
}
public static void initiate(){
try {
Properties properties = System.getProperties();
properties.setProperty("mail.imaps.auth.ntlm.disable", "false");
properties.setProperty("mail.protocol.ssl.trust", "true");
properties.put("mail.imap.starttls.enable", "true");
Session session = Session.getInstance(properties, null);
System.out.print("Connecting to the IMAP server...");
String storeName = "imaps";
Store store = session.getStore(storeName);
store.connect("imaps store address", 993,"[email protected]/SharedMailboxName","Password");
System.out.println("Connected To server: Done!");
Folder[] f = store.getDefaultFolder().list();
for(Folder fd:f)
System.out.println(">> "+fd.getName());
System.out.println();
Folder inbox = store.getFolder("inbox");
inbox.open(Folder.READ_WRITE);
Message messages[] = inbox.search(new FlagTerm(new Flags(Flag.SEEN), false));
}
catch(Exception E){
E.printStackTrace();
}
}
這是否與Outlook有關? –
我在你的代碼塊之前移動了你的問題陳述。用一些上下文消化代碼通常更容易。 – Chris
是的,我正在嘗試連接到Microsoft Exchange Outlook。我仍然有問題。 – Bramha