Skip to content

Instantly share code, notes, and snippets.

@kyanny
Created March 1, 2011 10:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kyanny/848966 to your computer and use it in GitHub Desktop.
Save kyanny/848966 to your computer and use it in GitHub Desktop.
raw_message = STDIN.read
email = TMail::Mail.parse(raw_message)
if email.has_attachments?
email.attachments.each do |attachment|
image = attachment.read
filename = attachment.original_filename
end
elsif email.content_type == 'image/jpeg'
image = email.body
filename = email.header['content-disposition'].params['filename']
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment