Advertisement
Guest User

Untitled

a guest
Feb 20th, 2016
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. def props = new Properties()
  2. props.put 'mail.store.protocol', 'imaps'
  3.  
  4. def host = 'imap.yandex.ru'
  5. def port = 993
  6. def username = 'username'
  7. def password = 'password'
  8.  
  9. def store = Session.getDefaultInstance(props, null).store
  10.  
  11. store.connect(host, port, username, password)
  12.  
  13. def inbox = store.getFolder('Inbox')
  14.  
  15. inbox.open(Folder.READ_ONLY)
  16.  
  17. def messages = inbox.messages
  18.  
  19. messages.each { Message message ->
  20. def from = message.getFrom().collect {javax.mail.Address address ->
  21. if (address instanceof InternetAddress)
  22. address.address
  23. else
  24. address.toString()
  25. }.join(';')
  26. def subject = message.subject
  27. println "$from\t$subject"
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement