How to embed picture into e-mail with mail gem (any lib)

And the picture will show (not as attachment) on gmail or outlook
client. This is what I am doing(according to what I have found on net),
but all I get is a square which tells where picture should be shown but
it isn’t.

require ‘net/smtp’
require ‘rubygems’
require ‘mail’

c =‘mygif.gif’,‘rb’) { |f| }
mail =
mail.subject = ‘Some subject’
mail.attachments[‘mygif.gif’] = c
id = mail.attachments.first.content_id.gsub(/<|>/,’’)

html_part = do
content_type ‘text/html; charset=UTF8’
body “

<img width=“800” height=“600” src=“cid: #{id}”>

mail.html_part = html_part

send_mail mail.to_s

I even tried this but it isn’t working neither.
body "<img width=“800” height=“600”


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