donald
donald

Reputation: 23737

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?

Upvotes: 3

Views: 1854

Answers (2)

michaeloboyle
michaeloboyle

Reputation: 11

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

Upvotes: 1

Vasiliy Ermolovich
Vasiliy Ermolovich

Reputation: 24617

Use ruby-gmail

gem install ruby-gmail mime

irb(main):001:0> require 'gmail'
=> true
irb(main):002:0> gmail = Gmail.new("[email protected]", "password")
=> #<Gmail:0x1ea65d8 ([email protected]) disconnected>
irb(main):004:0> gmail.inbox.count(:unread)
=> 42

Upvotes: 4

Related Questions