Defect #8093 » Add_function_to_extract_Outlook__msg_attachments_and_handle_them_correctly_as_attachments_.patch
| app/models/mail_handler.rb (revision caeea29efe2d9f02413452171eeddc656c614201) → app/models/mail_handler.rb (revision 1c8cba6492c70eb3ebca651c327b4e6d98c4bcb8) | ||
|---|---|---|
| 292 | 292 |
end |
| 293 | 293 | |
| 294 | 294 |
def add_attachments(obj) |
| 295 | ||
| 296 |
logger.info "Checking multipart" |
|
| 297 |
if email.parts |
|
| 298 |
email.parts.each do |part| |
|
| 299 |
if (part.content_disposition =~ /attachment/i) && (part.content_type = "message/rfc822") |
|
| 300 |
logger.info "Found email attachment in parts section" |
|
| 301 |
contents = part.decoded.gsub(0x0a.chr, 0x0d.chr+0x0a.chr) # this is to change newline type in attachment |
|
| 302 |
logger.info "Trying to parse it as email" |
|
| 303 |
attachment_email = Mail.new(contents) |
|
| 304 |
obj.attachments << Attachment.create(:container => obj, |
|
| 305 |
:file => contents, |
|
| 306 |
:filename => attachment_email.subject + ".eml", |
|
| 307 |
:author => user, |
|
| 308 |
:content_type => part.content_type) |
|
| 309 |
logger.info "Attachment added" |
|
| 310 |
end |
|
| 311 |
end |
|
| 312 |
end |
|
| 313 |
logger.info "Attachements added" |
|
| 314 | ||
| 315 | ||
| 295 | 316 |
if email.attachments && email.attachments.any? |
| 296 | 317 |
email.attachments.each do |attachment| |
| 297 | 318 |
next unless accept_attachment?(attachment) |
- « Previous
- 1
- …
- 6
- 7
- 8
- Next »