this sample code access inbox. works, need filter mails addressee because i'm using alias differents sites (mymail+alias1@gmail.com, mymail+alias2@gmail.com, mymail+alias3@gmail.com,...).
and there aren't message.getdeliveredto() or similar. idea? library? i'm using java mail api.
string host = "pop.gmail.com"; string username = "mymail@gmail.com"; string password = "password"; properties properties = new properties(); properties.put("mail.pop3.host", host); properties.put("mail.pop3.port", "995"); properties.put("mail.pop3.starttls.enable", "true"); session emailsession = session.getinstance(properties); store store = emailsession.getstore("pop3s"); store.connect(host, username, password); folder emailfolder = store.getfolder("inbox"); emailfolder.open(folder.read_write); message[] messages = emailfolder.getmessages(); (int = 0; < messages.length; i++) { mimemessage message = (mimemessage) messages[i]; system.out.println("---------------------------------"); system.out.println(message.getsender()); }
there address[] getrecipients()
method of class message
. every address has receipment type (to, cc, bcc). please refer java mail api: https://javamail.java.net/nonav/docs/api/javax/mail/message.html#getrecipients-javax.mail.message.recipienttype-
Comments
Post a Comment