Help is available for each task.
Task 1
Starting with the skeleton code, get or create a Properties object.
Properties props = new Properties();
Task 2
Get a Session object based on the Properties.
Session session = Session.getDefaultInstance(props, null);
Task 3
Get a Store for your email protocol, either pop3 or imap.
Store store = session.getStore("pop3");
Task 4
Connect to your mail host's store with the appropriate username and password.
store.connect(host, username, password);
Task 5
Get the folder you want to read. More than likely, this will be the INBOX.
Folder folder = store.getFolder("INBOX");
Task 6
Open the folder read-only.
folder.open(Folder.READ_ONLY);
Task 7
Get a directory of the messagesin the folder. Save the message list in an array variable named message.
Message message[] = folder.getMessages();
Task 8
For each message, display the from field and the subject.
System.out.println(i + ": " + message[i].getFrom()[0]
+ "\t" + message[i].getSubject());
Task 9
Display the message content when prompted.
System.out.println(message[i].getContent());
Task 10
Close the connection to the folder and store.
folder.close(false);
store.close();
Task 11
Compile and run the program, passing your mail server, username, and password on the command line. Answer YES to the messages you want to read. Just hit ENTER if you don't. If you want to stop reading your mail before making your way through all the messages, enter QUIT.
java GetMessageExample POP.Server username password