LoginSignup
4
3

More than 5 years have passed since last update.

Google API を使って Gmail からメールのタイトル一覧を取得するメモ

Last updated at Posted at 2017-08-24
require 'gmail'
gmail = Gmail.connect(:xoauth2, "gmailアカウント", "oauth2 のトークン")
gmail.inbox.find().each do |email|
  subject = email.message.Subject
  p subject.instance_variable_get(:@raw_value)
end

oauth2 のトークンの取得方法は
https://himakan.net/websites/how_to_google_oauth
を参考にする

gmail Gem で使える find のオプションは
https://github.com/gmailgem/gmail/blob/88eed664eb534a6499817a279659e6cf2a162fca/lib/gmail/mailbox.rb#L35-L48
のよう

4
3
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
4
3