我要讀用下面的代碼從Office 365的電子郵件,但它沒有連接到服務器:閱讀從Office 365郵箱在java中
private void init()
{
try{
Properties smtpProps = new Properties();
smtpProps.put("mail.host", "192.168.10.18");
smtpProps.put("mail.port", "995");
smtpProps.put("mail.transport.protocol", "imaps");
session = Session.getInstance(smtpProps,
new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("[email protected]","test");
}
});
System.out.println("session = "+session);
Store store = session.getStore("imaps");
store.connect();
Folder inbox = store.getFolder("INBOX");
inbox.open(Folder.READ_WRITE);
Message messages[] = null;
messages = inbox.search(new FlagTerm(new Flags(Flag.SEEN), false));
System.out.println("leng = "+messages.length);
}catch(Exception e)
{
e.printStackTrace();
}
}
什麼是堆棧跟蹤? –