troubleshooting Question

Java mail question(urgent)

Avatar of mikechen
mikechen asked on
JavaJava EE
5 Comments1 Solution434 ViewsLast Modified:
Can somebody tell me anything wrong with the following code ?  
The problem I have is
1. The Received date is null.
2. FromParty is garbage.
3. Sometimes, the sentdata is also null.

But when I configure Outlook Express to point to that server, it seems those information are correct.

Any hints ?

     // Create empty properties
     Properties props = new Properties();

     // Get session
     Session session = Session.getInstance(props, null);

     // Get the store
     Store store = session.getStore("pop3");

     // Connect to store
     store.connect(strPOP3Host, strUser, strPassword);

     // Get folder
     Folder folder = store.getFolder("INBOX");

     // Open read-only;

     // Get directory
     Message message[] = folder.getMessages();
     int     nTotalMessage = folder.getMessageCount();

     for (int i=0;i<nTotalMessage;i++)
          int          nMsgNo = 0;
          String     strFrom = "Unknown";
          String     strSubject = "Empty";

          // Get the message number
               nMsgNo = message[i].getMessageNumber();
               javax.mail.Address     address = message[i].getFrom()[0];
               strFrom = address.toString();
               nMsgNo = message[i].getMessageNumber();
               System.out.println("From:" + message[i].getFrom());
               System.out.println("Sent:" + message[i].getSentDate());
               System.out.println("Received:" + message[i].getReceivedDate());
        catch (Exception ex)



Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros