--00163645811099494e0465c235d0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

I would suggest looking at the MailFactory gem (
http://rubyforge.org/projects/mailfactory/). It has a simple way to
construct the mail message, with attachments, that you can then send using
net/smtp.

On Sun, Mar 22, 2009 at 9:55 PM, David Wright <david_v_wright / yahoo.com>wrote:

> Vetrivel Vetrivel wrote:
> > How to attach the filename in ruby. I have attach 1.txt as a file name .
> > The 1.txt
> > file has the following contents.
> >        This is a test message.
> > But  it doesn't work for me.
> >
> > require 'net/smtp'
> >
> > msgstr  <END_OF_MESSAGE
> > From: FromAddress
> > To: ToAddress
> > Subject: test message
> > Message-Id: <unique.message.id.string / example.com>
> > attachment: "1.txt"
> >
> >
> > END_OF_MESSAGE
> >
> > smtp  et::SMTP.start("IpAdd" , portno)
> > smtp.send_message msgstr, 'fromAddress, 'toAddress'
>
> I haven't personally used this module but looking at the docs,
> http://www.ruby-doc.org/stdlib/libdoc/net/smtp/rdoc/index.html I don't
> see an attachment option.
>
> You could however do this. (untested)
>
> mess_body ile.readlines('1.txt')
>
> msgstr  <END_OF_MESSAGE
> From: FromAddress
> To: ToAddress
> Subject: test message
> Message-Id: <unique.message.id.string / example.com>
>
> #{mess_body}
> END_OF_MESSAGE
>
> (did I win that 10,000 pound UK lotto yet?)
>
> --
> Posted via http://www.ruby-forum.com/.
>
>

--00163645811099494e0465c235d0--