6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?