Created
February 6, 2014 18:09
-
-
Save 3dd13/8849483 to your computer and use it in GitHub Desktop.
snippet to read your gmail emails by label
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'gmail' | |
require 'dotenv' | |
Dotenv.load | |
label_name = "" # label name here | |
Gmail.new(ENV["GMAIL_USERNAME"], ENV["GMAIL_PASSWORD"]) do |gmail| | |
mail_with_label = gmail.label(label_name) | |
count = mail_with_label.count | |
puts "Number of email for the label #{label_name}: #{count}" | |
first_email = mail_with_label.emails.first | |
puts "first_email: #{first_email.class}" | |
puts "first_email: #{first_email.send(:message).text_part}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment