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

Java: get email line count

Java: get email line count

import java.util.Properties;
import javax.mail.Authenticator;
import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.Part;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.URLName;
import javax.mail.internet.InternetAddress;
public class Emails_line
  public static void main(String[] args) throws Exception
     final String username="myusername";
     final String password="password-***";
    URLName url = new URLName("pop3://test@pop.gmail.com/Inbox");
    // open a session
    Session session = Session.getDefaultInstance(new Properties(),
    	 new Authenticator()
    	 	  public PasswordAuthentication getPasswordAuthentication()
                  return new PasswordAuthentication(username, password);
    Folder inbox = session.getFolder(url);
    if (inbox == null)
      System.out.println("inbox not found");
    Message[] messages = inbox.getMessages();
    for (int i = 0; i < messages.length; i++)
      System.out.println(messages[i].getLineCount() + " lignes");

Users who found this page were searching for:

  • list all usb devices
  • program of python to calculate fibonacci series
  • AffineTransform mooving

No comments yet.

Leave a Comment