Skip to content

Instantly share code, notes, and snippets.

@mmb
Created March 12, 2009 23:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mmb/78350 to your computer and use it in GitHub Desktop.
Save mmb/78350 to your computer and use it in GitHub Desktop.
get gmail unread count in ruby
#!/usr/bin/ruby
# gmail unread message count
require 'open-uri'
require 'rexml/document'
unread_count = open('https://mail.google.com/mail/feed/atom',
:http_basic_authentication=>['you', 'secret']) do |f|
doc = REXML::Document.new(f.read)
doc.root.elements['//feed//fullcount/text()'].value.to_i
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment