| Author |
Problem with Retriving mails from INBOX
|
shailesh Jammie
Greenhorn
Joined: Nov 14, 2005
Posts: 11
|
|
hi i m using the following code to get the messages from inbox, authentication is ok, try { // -- Get hold of the default session -- Properties props = System.getProperties(); Session session = Session.getDefaultInstance(props, null); // -- Get hold of a POP3 message store, and connect to it -- store = session.getStore("imap"); store.connect("e-smartsystems.com", "shailesh.jamloki@e-smartsystems.com", "sailesh"); System.out.println(store.isConnected()); // -- Try to get hold of the default folder -- folder = store.getDefaultFolder(); if (folder == null) throw new Exception("No default folder"); // -- ...and its INBOX -- folder = folder.getFolder("INBOX"); if (folder == null) throw new Exception("No POP3 INBOX"); System.out.println(folder.getMessageCount()); // -- Open the folder for read only -- folder.open(Folder.READ_ONLY); System.out.println(folder.getMessageCount()); // -- Get the message wrappers and process them -- Message[] msgs = folder.getMessages(); System.out.println("msg array length..."+msgs.length); for (int msgNum = 0; msgNum < msgs.length; msgNum++) { printMessage(msgs[0]); } } catch (Exception ex) { ex.printStackTrace(); } finally { // -- Close down nicely -- try { if (folder!=null) folder.close(false); if (store!=null) store.close(); } catch (Exception ex2) { ex2.printStackTrace(); } But i m not getting any messages in the message array? can any one help me ? what the problem is? my mail id is shailesh.jamloki@e-smartsystems.com regards shailesh
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16482
|
|
|
Your comments disagree with your code:Maybe that is the problem?
|
 |
shailesh Jammie
Greenhorn
Joined: Nov 14, 2005
Posts: 11
|
|
Originally posted by Paul Clapham: Your comments disagree with your code:Maybe that is the problem?
ya i try with that also store = session.getStore("pop3"); but it is still giving the same problem
|
 |
Seetesh Hindlekar
Ranch Hand
Joined: Feb 13, 2004
Posts: 244
|
|
Check if e-smartsystems.com is a POP3 server or not? If yes try this code String provider = "pop3"; Properties props = new Properties(); Session session = Session.getDefaultInstance(props, null); Store store = session.getStore(provider); store.connect(host, username, password); Folder inbox = store.getFolder("INBOX"); inbox.open(Folder.READ_ONLY); ..... Rgds, seetesh
|
 |
shailesh Jammie
Greenhorn
Joined: Nov 14, 2005
Posts: 11
|
|
hi i checked my pop3 server is mail.e-smartsystems.com. and checked by my code also. but stil it is not working? any other problem may be there? rgds shailesh
Originally posted by Seetesh Hindlekar: Check if e-smartsystems.com is a POP3 server or not? If yes try this code String provider = "pop3"; Properties props = new Properties(); Session session = Session.getDefaultInstance(props, null); Store store = session.getStore(provider); store.connect(host, username, password); Folder inbox = store.getFolder("INBOX"); inbox.open(Folder.READ_ONLY); ..... Rgds, seetesh
|
 |
Seetesh Hindlekar
Ranch Hand
Joined: Feb 13, 2004
Posts: 244
|
|
This is a working code for all POP3 servers. Pls check if port 110 is blocked or not. Rgds, Seetesh
|
 |
Seetesh Hindlekar
Ranch Hand
Joined: Feb 13, 2004
Posts: 244
|
|
Check for both port 25 and port 110 by executing a telnet ipaddress portno on the dos prompt. Rgds, Seetesh
|
 |
 |
|
|
subject: Problem with Retriving mails from INBOX
|
|
|