Created
February 24, 2009 19:00
-
-
Save ingramj/69719 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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