Index: app/models/mail_handler.rb IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/app/models/mail_handler.rb b/app/models/mail_handler.rb --- a/app/models/mail_handler.rb (revision caeea29efe2d9f02413452171eeddc656c614201) +++ b/app/models/mail_handler.rb (revision 1c8cba6492c70eb3ebca651c327b4e6d98c4bcb8) @@ -292,6 +292,27 @@ end def add_attachments(obj) + + logger.info "Checking multipart" + if email.parts + email.parts.each do |part| + if (part.content_disposition =~ /attachment/i) && (part.content_type = "message/rfc822") + logger.info "Found email attachment in parts section" + contents = part.decoded.gsub(0x0a.chr, 0x0d.chr+0x0a.chr) # this is to change newline type in attachment + logger.info "Trying to parse it as email" + attachment_email = Mail.new(contents) + obj.attachments << Attachment.create(:container => obj, + :file => contents, + :filename => attachment_email.subject + ".eml", + :author => user, + :content_type => part.content_type) + logger.info "Attachment added" + end + end + end + logger.info "Attachements added" + + if email.attachments && email.attachments.any? email.attachments.each do |attachment| next unless accept_attachment?(attachment)