7
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ruby-gmailを使ってGmailの重要な未読メールの件数を知る

Last updated at Posted at 2012-05-29
sudo gem install ruby-gmail pit mime

Pitの設定

ruby -e 'require "pit";Pit.set("google", :data=>{"username"=>"yuiseki", "password"=>"kogaidan"})'
gmail.rb
#!/usr/bin/env ruby
require 'pit'
require 'gmail'

config = Pit.get('google')
gmail = Gmail.new(config['username'], config['password'])
important_and_unread = gmail.mailbox('[Gmail]/Important').count(:unread)
puts important_and_unread

ワンライナー

ruby -e 'require"pit"; require"gmail"; g=Pit.get("google"); p Gmail.new(g["name"], g["pass"]).label("[Gmail]/Important").count(:unread)'
7
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?