This week's book giveaway is in the Testing forum.
We're giving away four copies of The Way of the Web Tester: A Beginner's Guide to Automating Tests and have Jonathan Rasmusson on-line!
See this thread for details.
Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to read inbox using javamail from microsoft exchange server through proxy server?

Neema Jacob
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I want to read mails from microsoft exchange server using javamail.I use the following code

String username = "";
String password = "sdasdas";

Properties props = System.getProperties();

Authenticator auth = new Authenticator()

public PasswordAuthentication getPasswordAuthentication()
return new PasswordAuthentication(username , password );
Session session = Session.getDefaultInstance(props, auth);


Store store = session.getStore("imaps");

store.connect(host, username, password);
// Get folder
Folder folder = store.getFolder("INBOX");;
// Get directory
Message message[] = folder.getMessages();
for (int i=0, n=message.length; i<n; i++) {
System.out.println(i + ": " + message[i].getFrom()[0]
+ "\t" + message[i].getSubject());
// Close connection

But I got error

javax.mail.MessagingException: Connection timed out: connect;
nested exception is: Connection timed out: connect
at com.sun.mail.imap.IMAPStore.protocolConnect(
at javax.mail.Service.connect(
at javax.mail.Service.connect(
at Shipmate.MyJavaMail.reaadMail(
at Shipmate.MyJavaMail.main(

I can access mails through Microsoft accesss office outlook in the configuration of that use connect to mymailbox using HTTP

2.In connection setting a Url is provided to connect to my proxyserver https//

3.mutually authenticate the session with ssl and provide the principal name for proxy server

4.And also basic authentication is used for connecting my proxy server for exchange.

The above are the settings done in my microsoft outlook 2003 so that I can read the mail in that.

But I would like to read inbox using Javamail.How can I do that?

Thanks in Advance
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic