Skip to content

Instantly share code, notes, and snippets.

@tsnow
Last active January 4, 2016 08:09
Show Gist options
  • Save tsnow/8593683 to your computer and use it in GitHub Desktop.
Save tsnow/8593683 to your computer and use it in GitHub Desktop.
Ruby script for Fourteen day count of gmail emails received
#!/usr/bin/env ruby
require 'gmail'
require 'optparse'
puts "user: "
user = gets.chomp
puts "pass: "
pass = gets.chomp
dates = ((Date.today - 14)...Date.today)
Gmail.new(user,pass) do |gmail|
all_mail = gmail.mailbox('[Gmail]/All Mail')
dates.each do |i|
p [
all_mail.count(:read, :on => i),
all_mail.count(:unread, :on => i),
all_mail.count(:on => i)
]
end
end
source 'https://rubygems.org'
gem 'ruby-gmail'
gem 'activesupport'
GEM
remote: https://rubygems.org/
specs:
activesupport (4.0.2)
i18n (~> 0.6, >= 0.6.4)
minitest (~> 4.2)
multi_json (~> 1.3)
thread_safe (~> 0.1)
tzinfo (~> 0.3.37)
atomic (1.1.14)
i18n (0.6.9)
mail (2.5.4)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime (0.2.0)
mime-types (1.25.1)
minitest (4.7.5)
multi_json (1.8.4)
polyglot (0.3.3)
ruby-gmail (0.3.0)
mail (>= 2.2.1)
mime (>= 0.1)
shared-mime-info
shared-mime-info (0.2.5)
thread_safe (0.1.3)
atomic
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.38)
PLATFORMS
ruby
DEPENDENCIES
activesupport
ruby-gmail
@tsnow
Copy link
Author

tsnow commented Jan 24, 2014

@anachronistic

Usage: bundle; bundle exec email-count
user: 
[email protected]
pass: 
password
[955, 31, 986]
[906, 0, 906]
[761, 0, 761]
[647, 35, 682]
[570, 54, 624]
[789, 24, 813]
[741, 64, 805]
[903, 39, 942]
[1113, 0, 1113]
[801, 3, 804]
[592, 47, 639]
[662, 46, 708]
[676, 45, 721]
[705, 30, 735]

That's a fourteen day count starting two weeks ago. The format is:
[read, unread, total]

It doesn't play nice with two-factor, you might have to make a one time password for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment