Skip to content

Instantly share code, notes, and snippets.

@goyuninfo
Created November 28, 2013 03:38
Show Gist options
  • Save goyuninfo/7686934 to your computer and use it in GitHub Desktop.
Save goyuninfo/7686934 to your computer and use it in GitHub Desktop.
Properties props = System.getProperties();
props.setProperty("mail.pop3.port", prop.getProperty("995"));
Session session = Session.getInstance(props, null);
Store store = session.getStore("imaps");
store.connect("pop.gmail.com", "name", "password");
javax.mail.Folder[] dfolders = store.getDefaultFolder().list("*");
for (Folder f : dfolders) {
System.out.println(f.getFullName());
if ((f.getType() & javax.mail.Folder.HOLDS_MESSAGES) != 0) {
System.out.println(f.getMessageCount());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment