Want to get the message form POP3


EJB design: Want to get the message form POP3

  1. Want to get the message form POP3 (1 messages)

    I want to get the message from POP3 server.

    The program which I used is

    //It retrives the messages from POP3 server

    import javax.mail.*;
    import javax.mail.internet.*;

    public class GetMessageFromPOP3 {
      public static void main (String args[])
          throws Exception {
        String host = args[0];
        String username = args[1];
        String password = args[2];

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

        // Get the store
        Store store = session.getStore("pop3");
        store.connect(host,110, username, password);

        // With out port no

        //store.connect(host,username, password);

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

        // Get directory
        Message message[] = folder.getMessages();
        for (int i=0, n=message.length; i<n; i++) {
           System.out.println(i + ": "
             + message[i].getFrom()[0]
             + "\t" + message[i].getSubject());

        // Close connection

    But it Gives Error:
    C:\javamailcollections>java GetMessageFromPOP3 mail.bigthings.com irapy xyz
    Exception in thread "main" javax.mail.NoSuchProviderException: No provider for p
            at javax.mail.Session.getProvider(Session.java:249)
            at javax.mail.Session.getStore(Session.java:323)
            at javax.mail.Session.getStore(Session.java:303)
            at GetMessageFromPOP3.main(GetMessageFromPOP3.java, Compiled Code)

    So what should i give in the place of host.
    please give me more details about the POP3 Servers.

  2. Download POP3.jar from Sun site and put it in your JRE\LIB\EXT folder.