Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Trying to connect Exhange Server

843834Nov 23 2007 — edited Nov 23 2007
I am getting error while connecting to outlook exchange server and getting exception as
DEBUG: getProvider() returning javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc]
* BYE Connection refused
javax.mail.MessagingException: * BYE Connection refused;
nested exception is:
com.sun.mail.iap.ConnectionException: * BYE Connection refused
at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:296)
at javax.mail.Service.connect(Service.java:234)
at javax.mail.Service.connect(Service.java:135)
at JavaMail_Outlook.main(JavaMail_Outlook.java:26)
java.lang.IllegalStateException: Not connected
at com.sun.mail.imap.IMAPStore.checkConnected(IMAPStore.java:950)
at com.sun.mail.imap.IMAPStore.getFolder(IMAPStore.java:801)
at JavaMail_Outlook.main(JavaMail_Outlook.java:32)
Exception in thread "main"


Code : // Create empty properties
Properties props = System.getProperties();
props.setProperty("mail.imap.socketFactory.fallback", "false");
props.setProperty("mail.imap.starttls.enable", "true");

// Get session
Session session = Session.getDefaultInstance(props, null);
session.setDebug(true);

// Get the store
Store store = session.getStore("imap");

// Connect to store - sky - is host and email id
try{
store.connect("sky", "pawan@anjaneya.com", "");
}catch(Exception e){
e.printStackTrace();
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 21 2007
Added on Nov 23 2007
1 comment
316 views