daily pastebin goal
50%
SHARE
TWEET

Untitled

a guest Dec 16th, 2018 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void emailtest(String user, String pass, String server, String port, String folder, String timeout) {
  2.     Properties props = new Properties();
  3.     props.put("mail.store.protocol", "imap");
  4.     props.put("mail.imap.host", server);
  5.     props.put("mail.imap.port", port);
  6.     props.put("mail.imap.ssl.enable", "true");
  7.  
  8.     Session session = Session.getInstance(props, null);
  9.     try (Store store = session.getStore("imap")) {
  10.         System.out.println("Establishing connection to: " + server);
  11.         store.connect(user, pass);
  12.         System.out.println("Connected!");
  13.  
  14.         Folder def = store.getDefaultFolder();
  15.         Folder[] tmp = def.list("*");
  16.         Folder[] folders = new Folder[tmp.length + 1];
  17.         System.arraycopy(tmp, 0, folders, 0, tmp.length);
  18.         folders[tmp.length] = def; // this is the root folder
  19.  
  20.         for(Folder f : folders)
  21.             System.out.println("Foldername: " + f.getName());
  22.  
  23. // .... further processing of folder contents
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top