1 25 26 package org.snipsnap.util.mail; 27 28 import org.radeox.util.logging.Logger; 29 30 import javax.mail.*; 31 import java.util.Properties ; 32 33 39 40 public class ReadMail { 41 public static void main(String [] args) { 42 String host = "tanis.first.fhg.de"; 43 String username = "SnipSnap/hq, mgmt"; 44 String password = "SMB2003"; 45 46 try { 47 Properties props = new Properties (); 49 50 Session session = Session.getDefaultInstance(props, null); 52 53 Store store = session.getStore("pop3"); 55 store.connect(host, username, password); 56 57 Folder folder = store.getFolder("INBOX"); 59 folder.open(Folder.READ_ONLY); 60 61 Message message[] = folder.getMessages(); 63 64 for (int i = 0, n = message.length; i < n; i++) { 65 Logger.debug(i + ": " + message[i].getFrom()[0] 66 + "\t" + message[i].getSubject()); 67 } 68 69 folder.close(false); 71 store.close(); 72 } catch (MessagingException e) { 73 Logger.warn("Error reading message", e); 74 } 75 } 76 } 77 | Popular Tags |