LoginSignup
6
6

More than 5 years have passed since last update.

Mail で2行になってるSubjectを取得するには?

Posted at

メール系で便利な Mail gem。
しかし2つになってしまってる日本語Subjectの場合、subjectメソッドでは一つしか取ることが出来なかった。
やり方が悪いのかな?

しょうがないからこうして採った。

require 'mail'
require 'nkf'

Mail.defaults do
   retriever_method(:pop3,
                    address: 'mypop',
                    port: 110,
                    user_name: 'myaccount',
                    password: 'maypass'
                    )
end

Mail.all.each do |mail|
   sub = mail[:Subject].value    #生Subjectデータ
   subject = NKF::nkf('-mw',sub) #BASE64からUTF-8へ
....
end
6
6
2

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
6
6