Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > How to embed picture into e-mail with mail gem (any lib)

Thread Tools

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

Damjan Rems
Posts: n/a
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 "<p><img width=\"800\" height=\"600\" src=\"cid: #{id}\"></p>"
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\"

Posted via

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
gemspec: How to install a Ruby extension into GEM/lib/SOME_DIR/rather than GEM/lib/ IƱaki Baz Castillo Ruby 1 02-28-2011 03:26 PM
RubyGems 0.9.1 calling a gem with gem '<gem>' Austin 7873 Ruby 5 01-27-2007 10:05 PM
ERROR: While executing gem ... (Gem::GemNotFoundException) Could not find rubygems-upodate (> 0) in the repository han Ruby 1 10-24-2005 10:28 PM
[ANN] Getopt-Declare 1.12 (gem/zip) and GGEnv (gem/zip) gga Ruby 0 07-18-2005 03:21 PM