Skip to content

Instantly share code, notes, and snippets.

@ingramj
Created February 24, 2009 19:00
Show Gist options
  • Save ingramj/69719 to your computer and use it in GitHub Desktop.
Save ingramj/69719 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
# Save attachments from a saved email.
require 'rubygems'
require 'tmail'
return 1 unless ARGV.size > 0
ARGV.each do |in_file|
mail = TMail::Mail.load(in_file)
if mail.has_attachments?
mail.attachments.each do |a|
f = File::new(a.original_filename, 'w')
f.write(a.read)
f.close
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment