Welcome to Working With Rails

 

Discussion Forums

Discuss all things Ruby on Rails with perhaps the web's most vibrant group of Ruby on Rails enthusiasts.
How to create image embeded e mail using action mailer
3 Posts
How to create image embeded e mail using action mailer

Hai All,

I have seen often mail with images embedded in it. In my rails application I use action mailer to send mails. What I want is give a stylish look to the mail by embedding images to the mail body. Can any one help me ?

Thanks In Advance

You can create HTML templates for your message bodies, just as you would create plain text templates. Use the same name, but use the .html.erb extension rather than .plain.erb. You'll most likely want to send multipart messages so people who don't want HTML emails can still read your messages. Check out the documentation for the #part method in ActionMailer.

One thing to watch out for: you'll need to fully qualify the paths to links and images, most likely by providing a protocol, host, and port to the ActionMailer::Base#default_url_options hash. Unlike ActionController templates, ActionMailer templates don't have access to the protocol/host/port of the current request.

Hi Brijith. I think what you are asking for is how to create inline attachements for e-mails. Where the image is attached to the e-mail, but still referenced in the HTML portion of the mail?

I found a plugin called inline_attachements that might help.

There is an article on how to use it here: http://blog.thoughtobject.com/2007/05/26/5/

It is a bit old, but it's worth a shot, and you will probably figure it out with the help of that article (the trick is to reference the images with "cid:...". You will see in the article).

Good luck.

3 Posts
Login to add your message