【发布时间】:2011-10-06 20:03:09
【问题描述】:
我正处于整个电子邮件及其部分以正确的顺序和嵌套生成的地步……除了一件小事。 :part_container 参数在 text/html 部分上方而不是下方插入内联附件。如果它在上面,Thunderbird 将不会显示任何内容,它会将电子邮件显示为具有 2 个外部附件。如果我手动编辑电子邮件并将内联部分移动到 text/html 部分下方,它会完美显示。
part :content_type => 'multipart/alternative' do |copy|
copy.part :content_type => 'text/plain' do |plain|
plain.body = render(
:file => "main.text.plain",
:body => {
:user => @user,
:text => docParse.to_plain_text
}
)
end
copy.part :content_type => 'multipart/related' do |rel|
rel.part :content_type => 'text/html' do |html|
html.body = render(
:file => "main.text.html",
:body => {
:part_container => rel,
:user => @user,
:content => content,
:email_links => m.email_links,
:nav_image => m.nav_image
}
)
end
end
end
m.attachments.each do |file|
attachment :content_type => "application/octet-stream",
:filename => File.basename(file),
:body => File.read(file)
end
需要明确的是,inline_attachments gem 可以在没有任何代码的情况下完美运行——但这只是在我发送没有任何外部附件的电子邮件(仅限内联图像)时。当我想发送带有内嵌图像和外部附件的 HTML 电子邮件时,这就是我不得不求助的方法。
编辑:明确地说,我的问题是“我如何确保在使用 :part_container 的 text/html 部分之后生成内联附件部分?
【问题讨论】:
标签: ruby-on-rails ruby email attachment