How to add mime module to sent email ruby

Hi
I am looking in google for long time about how to sent email with inline
image. and got this site

http://rubydoc.info/gems/mime/frames

i have installed gem install mime
its installed
but dont understand how to include MIME module in the code ..

"The following examples imply that the MIME module is included."

i am trying

require 'rubygems'
require 'mime'
msg = Message.new # creates a blank message with
date and message ID headers
  msg.date = (Time.now - 3600).rfc2822 # specify a different date
  msg.subject = 'This is important'
  msg.headers.add('X-Priority', 'high') # custom header

  msg.body = TextMedia.new('hello, it is me!')

···

#
  # The following snippets are equivalent to the previous line.
  #
  # msg.body = "\r\nhello, it is me!"
  # msg.header.add('Content-Type', 'text/plain; charset=us-ascii')
  #
  # --OR--
  #
  # msg.body = "Content-Type: text/plain;
charset=us-ascii\r\n\r\nhello, it is me!"

  msg.to = {
    'test@gmail.com' => Fosiul, # no name display
    'test@gmail.com' => 'Fosiul',
    'test@gmail.com' => 'Fosiul',
  }
  msg.from = {
    'test@gmail.com' => 'Boss Man'
  }

  msg.to_s # ready to be sent via SMTP

but

i get "uninitialized constant Message (NameError) "

problem is, how to refer that in the script ?

thanks

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

Hi
I am looking in google for long time about how to sent email with inline
image. and got this site

File: README — Documentation for mime (0.4.4)

i have installed gem install mime
its installed
but dont understand how to include MIME module in the code ..

"The following examples imply that the MIME module is included."

In Ruby you can include a module into your own class,
but you probably would not want to do that.

i am trying

require 'rubygems'
require 'mime'
msg = Message.new

i get "uninitialized constant Message (NameError) "

The Message class is part of the MIME module, try

   msg = MIME::Message.new

···

Am 06.10.2012 14:46, schrieb Ferdous ara:

--
<https://github.com/stomar/&gt;

Hi thanks

thats work but then i dont think it does sent anything

dont i have to define smtp ??

becase end of the code its saying

msg.to_s # ready to be sent via SMTP

where is the smtp code ??

···

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

HI thanks

then how will i sent email ??

will it work with net/smtp module ??

···

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

yes its works with net/smtp

···

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

same problem if i use net/smtp .. image does not work as inline ..

···

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

This is not a Ruby question, it's about MIME.

For information about how to format a MIME mail with HTML and inline
images, see RFC 2387 and RFC 2392. RFC 2392 has an example of exactly
this:

  "The following message contains an HTML body part that refers to an
   image contained in another body part. Both body parts are contained
   in a Multipart/Related MIME entity. The HTML IMG tag contains a
   cidurl which points to the image."

···

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

Sorry, posted reply to wrong thread :frowning:

···

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

Yes, it is only "ready to be sent"...

···

Am 06.10.2012 16:50, schrieb Ferdous ara:

Hi thanks

thats work but then i dont think it does sent anything

dont i have to define smtp ??

becase end of the code its saying

msg.to_s # ready to be sent via SMTP

where is the smtp code ??

--
<https://github.com/stomar/&gt;