RubyでGmailを使う

文字化けにやられた。
http://stackoverflow.com/questions/11039522/character-encoding-with-ruby-1-9-3-and-the-mail-gem

# coding:utf-8                                                                           
require 'gmail'

gmail = Gmail.connect("YOUR_GMAIL_ACCOUNT","YOUR_GMAIL_PASSWORD")
message = gmail.inbox.mails(:to => "target@mail.account").first
body = message.body.decoded.force_encoding(message.charset).encode("UTF-8")

print body