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 = File.open(‘mygif.gif’,‘rb’) { |f| f.read }
mail = Mail.new
mail.subject = ‘Some subject’
mail.attachments[‘mygif.gif’] = c
id = mail.attachments.first.content_id.gsub(/<|>/,’’)

html_part = Mail::Part.new do
content_type ‘text/html; charset=UTF8’
body “

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


alt=“somename”>"
end
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”
src=“data:image/gif;base64,#{Base64.b64encode©}”

by
TheR

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