views:

76

answers:

1

I'm using the following code to retrieve emails from my Gmail inbox.

def get_mail
  Net::POP3.enable_ssl(OpenSSL::SSL::VERIFY_NONE)  
  Net::POP3.start('pop.gmail.com', 995, "uname","pass") do |pop|  
  unless pop.mails.empty?
       pop.each_mail do |mail|  
        email = TMail::Mail.parse(mail.pop)
        email_obj=EmailedQueries.new
        email_obj.save_email(email.from,email.subject,email.body_html)        
        end 
    end
 end   
end

This works just fine, but it retrieves only new mails from the inbox. Instead, I want a seperate function that will retrieve ALL emails from the inbox. This function will be used rarely. I wont be retrieving all mails all the time. Only when necessary.

Thanks!

+1  A: 

You'll need to configure POP settings in GMail.Enable "Pop for all mail" and you're good to go !

Shreyas Satish
thanks! it worked!
Kartik Rao