电子邮件中的PDF附件称为“Noname” [英] PDF attachment in email is called 'Noname'

查看:498
本文介绍了电子邮件中的PDF附件称为“Noname”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我发送带有附件pdf文件的电子邮件时,电子邮件仅显示一个名为Noname的文件。该文件本身是电子邮件的多部分,附有base64附件pdf。如何发送PDF,作为附件出现,不会损坏电子邮件?



这是我的代码:


$

$($ to $&$ ;电子邮件,主题=>主题,身体=>消息,content_type =>'application / pdf')


解决方案

我遇到同样的问题。我已经通过以下方式更正了



1)根据ActionMailer指南,您需要将视图文件放入app / views / [action_mailer_model_name] / [method_name]



以下是指南参考: http:/ /api.rubyonrails.org/classes/ActionMailer/Base.html



2)Action Mailer非常聪明,可以在阅读文件时自动识别内容类型。所以没有必要明确地在你的邮件功能中通过'application / pdf'。



希望这个信息有助于解决你的问题


When I send an email with a attached pdf file the email only shows a file called 'Noname'. The file itself is the multipart section of the email with the base64 attached pdf. How can I send the PDF so it comes up as an attachment and doesn't corrupt the email?

Here is my code:

attachments['126539_statistics.pdf'] = File.read("app/assets/pdfs/126539_statistics.pdf")
mail(:to => email, :subject => subject, :body => message,  :content_type => 'application/pdf') 

解决方案

I had face same problem. I have corrected it by following way

1) As per ActionMailer Guide, You need to make view file into app/views/[action_mailer_model_name]/[method_name]

Here is reference of guide: http://api.rubyonrails.org/classes/ActionMailer/Base.html

2) Action Mailer is smart enough that it identify content-type automatically while reading file. So there is no need to pass explicitly 'application/pdf' in your mail function.

Hope, this information helps to solve your problem

这篇关于电子邮件中的PDF附件称为“Noname”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆