Rails 2.3.5 では、次のコードを使用して、マルチパート メールである他のメールに添付ファイルとしてメールを添付することができました。
recipients to
from from
subject subject
content_type "multipart/mixed"
part "text/html" do |p|
p.body = render_message("rampup_notification.text.html.erb", :mailbody => body)
end
part "text/plain" do |p|
p.body = render_message("rampup_notification.text.plain.erb", :mailbody => body)
end
email = enrollment_application.email
if email != nil && email.raw_email != nil
attachment :content_type => "message/rfc822", :filename => "icann.eml", :body => email.raw_email, :transfer_encoding => '7bit'
end
これは、他のメーラーと一緒に Outlook や Exchange などを使用するのに非常に気まぐれでした。
Rails 3でこれを行うにはどうすればよいですか?
なるほど: http://www.rubydoc.info/docs/rails/3.0.0/ActionMailer/Base:attachments
encoded_content = SpecialEncode(File.read('/path/to/filename.jpg'))
attachments['filename.jpg'] = {:mime_type => 'application/x-gzip',
:encoding => 'SpecialEncoding',
:content => encoded_content }
しかし、私はこれを使用する方法を理解していません.SpecialEncodeは、7ビットエンコーディングを行うために書く必要があるクラスですか?
ありがとうジョエル