Powered by Ajaxy
Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

JavaMail: How to read Yahoo and Gmail inboxes

JavaMail: How to read Yahoo and Gmail inboxes

import java.util.Properties;
import javax.mail.Authenticator;
import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Store;
public class Java_Email {
 private static void Read_Message(final String host, final String username, final String password)
 	throws  Exception
    // Set the connection parameters
 	Session session = Session.getDefaultInstance(new Properties(),
 	    	 new Authenticator()
    	 	  public PasswordAuthentication getPasswordAuthentication()
                  return new PasswordAuthentication(username, password);
    Store store = session.getStore("pop3");
    // Open the connection
     store.connect(host,username, password);
 	 System.out.println ("You're now connected to "+host);
 	// Opening the mailbox
 	 Folder inbox = store.getFolder("INBOX");
    if (inbox == null) {
      System.out.println("INBOX not found");
    // Select all messages in current folder(inbox)
    Message[] messages = inbox.getMessages();
    // print selected messages
    System.out.println ("Inbox message count: "+messages.length+" message(s)");
    System.out.println ();
    // display one message
  public static void main(String[] args) throws Exception
  	 // GMail Example
     // Yahoo Example

Users who found this page were searching for:

  • javamail yahoo read inbox
  • python bind
  • javamail yahoo Gmail 一覧
  • check if an element exists in a dictionary python
  • select Jbutton java swing
  • how to read gmails whit a programme
  • how to read mail from yahoo with java mailing
  • read yahoo mail using java

No comments yet.

Leave a Comment