Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Mail Retieval

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
following programm is giving me error as 'NoRoutetoHostException' can
you help me in above problem.
> The programm is as follows:
>
> file://java GetMessageExample <pop.server.com> <username> <password>
>
>
> import java.io.*;
> import java.util.Properties;
> import javax.mail.*;
> import javax.mail.internet.*;
>
> public class GetMessageExample {
> public static void main (String args[]) throws Exception {
> String host = args[0];
> String username = args[1];
> String password = args[2];
>
> // Create empty properties
> Properties props = new Properties();
>
> // Get session
> Session session = Session.getInstance(props, null);
>
> // Get the store
> Store store = session.getStore("pop");
> store.connect(host, username, password);
>
> // Get folder
> Folder folder = store.getFolder("INBOX");
> folder.open(Folder.READ_ONLY);
>
> BufferedReader reader = new BufferedReader(new
InputStreamReader(System.in));
>
> // Get directory
> Message message[] = folder.getMessages();
> for (int i=0, n = message.length;i<n; i++)<br /> > {
> System.out.println(i + ":" + message[i].getFrom()[0] +
> "\t" + message[i].getSubject());
> System.out.println( "Do you want to read message? [YES to
read/QUIT to end]");
> String line = reader.readLine();
>
> // Mark as deleted if appropriate
> if("YES".equals(line)) { message[i].writeTo(System.out); }
> else if ("QUIT".equals(line))
> { break; }
> }
>
> // Close connection
> folder.close(false);
> store.close();}
> }
>
 
Ranch Hand
Posts: 72
Eclipse IDE Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
Are you running this program behind a proxy?
thanks and regards
ravee.
 
yogesh naravane
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
no i am not running this programm behind fire wall
 
Ravee Bhat
Ranch Hand
Posts: 72
Eclipse IDE Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Yogesh,
can you post the stackTrace? And what are you using as the host?
thanks and regards
ravee
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic