• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem with Retriving mails from INBOX

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your comments disagree with your code:Maybe that is the problem?
 
shailesh Jammie
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is a working code for all POP3 servers.

Pls check if port 110 is blocked or not.

Rgds,

Seetesh
 
Seetesh Hindlekar
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check for both port 25 and port 110 by executing a telnet ipaddress portno on the dos prompt.

Rgds,

Seetesh
 
reply
    Bookmark Topic Watch Topic
  • New Topic