--- mail_handler.rb 2012-08-22 15:59:07.679089551 +1000 +++ mail_handler2.rb 2012-08-22 16:00:16.234145227 +1000 @@ -243,12 +243,19 @@ def add_attachments(obj) if email.attachments && email.attachments.any? - email.attachments.each do |attachment| - obj.attachments << Attachment.create(:container => obj, - :file => attachment.decoded, - :filename => attachment.filename, - :author => user, - :content_type => attachment.mime_type) + email.attachments.each_with_index do |attachment, i| + if attachment.content_type == 'message/rfc822' + attachment.original_filename = "attachments" + i.to_s() + ".eml" + obj.attachments << Attachment.create(:container => obj, + :file => attachment, + :author => user, + :content_type => attachment.content_type) + else + obj.attachments << Attachment.create(:container => obj, + :file => attachment, + :author => user, + :content_type => attachment.content_type) + end end end end