ActiveMailer HTML + Plain Text + Attachment?

How do you do this?

Tried all the examples on the wiki, and unfortunately the trac is not
accessible right now to check the trouble tickets.

No matter what I do the mime structure seems to be incorrect.

It seems that adding an attachment to a html+plaintext message is not
possible using the standard methods. I have seen some old posting on the
mailing list about overriding the deliver method to add attachments
after creating the message.

Is this so? Does anyone have a working example?

Here is one of many contortions I have tried:

def answer(message, representative, sent_at = Time.now)
    @subject    = message.reply_subject
    @recipients = message.sender.address
    @from       = message.team.reply_from_address
    @sent_on    = sent_at
    @content_type = "multipart/alternative"

    part "text/html" do |p|
      p.body = render_message("answer_as_html", :message => message, 
:signature => representative.signature)
    end

    part "text/plain" do |p|
      p.body = render_message("answer_as_plain", :message => message, 
:signature => representative.signature)
      p.transfer_encoding = "base64"
    end

    attachment message.attachment.content_type do |a|
      a.body = attachment.body
      a.filename = attachment.filename
    end

  end

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs