Project

General

Profile

Defect #8093 » Add_function_to_extract_Outlook__msg_attachments_and_handle_them_correctly_as_attachments_.patch

Dirty patch for Redmine 4.2.3 - Jan Catrysse, 2022-06-22 16:56

View differences:

app/models/mail_handler.rb (revision caeea29efe2d9f02413452171eeddc656c614201) → app/models/mail_handler.rb (revision 1c8cba6492c70eb3ebca651c327b4e6d98c4bcb8)
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)
(8-8/8)