Velocity Reviews - Computer Hardware Reviews

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

Reply
Thread Tools

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

 
 
Damjan Rems
Guest
Posts: n/a
 
      09-07-2010
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:art.new do
content_type 'text/html; charset=UTF8'
body "<p><img width=\"800\" height=\"600\" src=\"cid: #{id}\"></p>"
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(c)}\"


by
TheR
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
Reply

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



Advertisments