Monday, April 30, 2012

Need help on reading emails with "mail" gem in ruby

I am doing automation using Watir that creates an email that I need to check. I was pointed at the email gem as being the easiest way to do this.



I added following code and am able to get first email from my inbox.



require 'mail' 
require 'openssl'

Mail.defaults do
retriever_method :pop3, :address => "email.someemail.com",
:port => 995,
:user_name => 'domain/username',
:password => 'pwd',
:enable_ssl => true
end

puts Mail.first


I am new to this forum and have following questions :




  1. How can I get all the unread emails? I tried Mail.all, Mail.first, Mail.last, but nothing returns unread email.


  2. How can I get all links that are present inside emails? Or mail message body from the specific email? I need to get the email body of first unread email.


  3. How can I get emails from a specific folder, if I have subfolders inside my inbox?






No comments:

Post a Comment