2

I am using ActionMailer to send an inline image. The user_mailer.rb file looks like this:

def welcome_mail(user, mail_content, subject) 
  @user = user 
  @mail_content = mail_content.html_safe 
  attachments.inline['orglogo.png'] = File.read("#{Rails.root}/app/assets/images/orglogo.png") 
  mail(:to => ["testuser@domain.com"],:Subject => subject) 
end 

And the view contains:

<%= image_tag attachments['orglogo.png'].url %> 

The image isn't appearing in the mail. This is how it appears in the mail client. I have tested on Outlook and Hotmail.

Inline attachment

Nilesh C
  • 697
  • 2
  • 7
  • 17
  • Just to be clear. I did my homework before posting this. The solution mentioned here -- http://stackoverflow.com/questions/8356924/rails-attachments-inline-are-not-shown-correctly-in-gmail, does not work for me. – Nilesh C May 15 '13 at 23:24

2 Answers2

2

In my production app we are sending inline image using the above method and for me everything is working very fine for me. So i created the public gist for that working snippet of code. Please see if it helps you. GistPublic gist with mailers

If doesn't work please try to paste your development.log here.

Thanks

Vivek Parihar
  • 2,318
  • 18
  • 18
  • Thanks for this Vivek. I had tried specifying the MIME types for the inline images. However no change. The image appears broken. No errors are generated in the development.log file. – Nilesh C May 20 '13 at 04:20
0

Well, the solution or rather workaround that worked was to upgrade to Rails 4. I am able to send inline images without any problem in Rails 4.

Nilesh C
  • 697
  • 2
  • 7
  • 17