[Tmail-talk] Reading Forwarded Messages

Mikel Lindsaar raasdnil at gmail.com
Thu Jan 17 00:26:45 EST 2008

> On Jan 4, 2008 6:25 PM, Bira <u.alberton at gmail.com> wrote:
> > First, I would like to apologize for asking a question which may be
> > obvious to the people here. I tried searching the documentation at
> > tmail.rubyforge.org, but I couldn't find any answers.

Hey, no problem, that is what this list is for, though I am sorry it
took me so darn long to answer you! :)

> > How does TMail handle forwarded messages? I've seen something in the
> > documentation about creating forwards, but I want to do the opposite -
> > given an e-mail message which contains one or more forwarded messages,
> > how do I acess them?

Ok, you have a file that has an image in it... you can do something like this:

irb> require 'rubygems'
irb> require 'tmail'
irb> m = TMail::Mail.load('email_with_attachment.txt')
irb> m.has_attachments?
=> true
irb> m.attachments
=> [#<TMail::Attachment:0x14e44a8>, #<TMail::Attachment:0x14e4084>]
irb> m.attachments[0].read

Basically, an attachment inherits from the StringIO class, and
StringIO class in TMail has the ability to read and write.

So you can just read in the file, then write it out to disk and you
should be good.

Hope that helps.

This is definately somewhere where a bit more documentation would be
useful.  Wanna help out?


More information about the Tmail-talk mailing list