# ActionMailer Inline Image Attachment Issue

**URL:** <https://www.ruby-forum.com/t/actionmailer-inline-image-attachment-issue/65289>\
**Category:** Ruby\
**Created:** [February 10, 2006, 8:39am UTC](https://www.ruby-forum.com/t/actionmailer-inline-image-attachment-issue/65289 "2006-02-10T08:39:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [February 10, 2006, 8:39am UTC](https://www.ruby-forum.com/t/actionmailer-inline-image-attachment-issue/65289/1 "2006-02-10T08:39:47Z")

</div>

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 = “removed\_email\_address@domain.invalid”  
@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
