Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Javamail problem  RSS feed

 
kandarp Bhatt
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am working on Javamail. I face a problem. When I try to get messages from inbox and if inbox will empty it throws exception, and below that I post code.
Thanks in advance
Kandarp

 
Charles Dupin
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why dont you retrieve one message at the time and check availability with if(folder.getMessageCount() > 0).
 
Pradeep Peiris
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Set the property "mail.pop3.socketFactory.fallback" as false and see. By default this property is set as true and it tries to create a socket using the java.net.Socket when it fails to create a socket using the specified socket factory. http://java.sun.com/products/javamail/javadocs/com/sun/mail/pop3/package-summary.html

sample code:

Properties props = System.getProperties();
props.setProperty("mail.pop3.socketFactory.fallback", "false");
Session session = Session.getInstance(props, null);
.
.
.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!