Cara Instalasi
gem install ruby-gmail
Berikut adalah contoh kode untuk mengambil seluruh unread message gmail.
#!/usr/bin/ruby
require 'rubygems'
require 'gmail'
username = "YOUR_USERNAME"
password = "YOUR_PASSWORD"
gmail = Gmail.new(username, email)
unread_message = gmail.inbox.emails(:unread)
puts "All unread messages"
for mail in unread_message
puts "----------------------------------"
puts "From: #{mail.message.from}"
puts "Subject: #{mail.message.subject}"
end
No comments:
Post a Comment