ActionMailer Inline Image Attachment Issue

Discussion in 'Ruby' started by beanbrown@gmail.com, Feb 10, 2006.

  1. Guest

    I have been wholely unsuccessful in having an inline image attachment
    show in an HTML email. I have been able to create an email with plain,
    html and image parts, but when attempting to set the content-id for an
    image (so that I can refer back to it in the HTML), I am unable to get
    it to appear using the headers attribute of the attachment.

    Here is my code:
    class Mailer < ActionMailer::Base

    def email_html( user, to, subject, message )
    @recipients = ""
    @from = user.emailaddr
    @subject = subject

    part :content_type => "text/html",
    :body => "<b>Welcome to <img src=\"cid:img1\" border=1>!</b>"

    part "text/plain" do |p|
    p.body = "this is plain"
    p.transfer_encoding = "base64"
    end

    attachment :content_type => "image/gif",
    :headers => {'content-id' => 'img1'},
    :body => File.read("c:\temp\logo.gif"),
    :filename => "logo"

    # this works
    self.parts[self.parts.length-1].filename = 'foo'

    # this does not work
    self.parts[self.parts.length-1].headers['content-id'] = 'bar'

    end

    end

    # Please help!
    # Eric
    , Feb 10, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. enspired
    Replies:
    3
    Views:
    205
    enspired
    Jul 28, 2005
  2. Kevin Brown

    ActionMailer

    Kevin Brown, Nov 20, 2005, in forum: Ruby
    Replies:
    2
    Views:
    93
    Jeremy Kemper
    Nov 20, 2005
  3. Replies:
    1
    Views:
    189
    Poornima Dhanasekar
    Feb 19, 2009
  4. John N. Alegre
    Replies:
    7
    Views:
    211
    David Vallner
    Feb 23, 2006
  5. dkmd_nielsen
    Replies:
    1
    Views:
    179
    Gregory Brown
    Dec 15, 2009
Loading...

Share This Page