On 6/04/2008, at 1:13 AM, Volker Kuhlmann wrote:
Jim's suggestion
http://docs.python.org/lib/module-email.html
is yet another reason to learn python.

Or learn ruby :)

require 'tmail'
message = TMail::Mail.load("/tmp/mime-email.txt")
message.attachments.size
# => 1
image = message.attachments.first
image.original_file
# => "IMG_0025.jpg"
image.size
# => 444368

It is a StringIO, so you have IO access to this "file" stored in memory.
You could do something like:

File.open("/tmp/my_image.jpg", "w") do |f|
 f.write image.read
end

I believe the source is available through rubygems.
http://tmail.rubyforge.org/

Ciao,
Tim

Reply via email to