Check unread count of Gmail messages with Ruby
How can I check the number of unread Gmail message in my inbox with a short Ruby script开发者_如何转开发?
Use ruby-gmail
gem install ruby-gmail mime
irb(main):001:0> require 'gmail'
=> true
irb(main):002:0> gmail = Gmail.new("email@gmail.com", "password")
=> #<Gmail:0x1ea65d8 (email@gmail.com) disconnected>
irb(main):004:0> gmail.inbox.count(:unread)
=> 42
Nash's solution worked for me once I added require 'rubygems'
as the first step.
Before I did that I would get the following error when using require 'gmail'
.
LoadError: no such file to load -- gmail
精彩评论