Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling outlook .msg attachments (rfc822) as attachments #1492

Open
jcatrysse opened this issue Jun 22, 2022 · 3 comments
Open

Handling outlook .msg attachments (rfc822) as attachments #1492

jcatrysse opened this issue Jun 22, 2022 · 3 comments

Comments

@jcatrysse
Copy link

Hello,

This issue concerns Redmine 4.2.3, who is using this mail gem to handle incoming mails.

We have an issue when using forward mail as attachment from Outlook and sending the message to Redmine (who is using this mail gem). Normally, on reception, we would expect to receive the mail message and the added .msg attachment as an attachment. This is not the case.

We get the mail message, all the other attachments from the mail, but also from the added .msg attachment. But never the .msg attachment itself.

The .msg attachment is encoded like this:

...
--_012_342b0886c5894875a2dadf9b72a8b986TRUSTMBX01TRUSTTEAMLOCA_
Content-Type: message/rfc822
Content-Disposition: attachment;
	creation-date="Tue, 21 Jun 2022 16:05:12 GMT";
	modification-date="Tue, 21 Jun 2022 16:05:12 GMT"
...

And not like this:

--_012_9f65674b87e2415387c04fb36bdc7d93TRUSTMBX01TRUSTTEAMLOCA_
Content-Type: application/octet-stream; name="test_message .msg"
Content-Description: test_message .msg
Content-Disposition: attachment; filename="test_message.msg"; size=274579;
	creation-date="Tue, 21 Jun 2022 16:03:48 GMT";
	modification-date="Wed, 22 Jun 2022 13:27:38 GMT"
Content-Transfer-Encoding: base64

What can we do, just to handle rfc822 parts as an attachment?

All help is very much appreciated.

@jcatrysse
Copy link
Author

I added some dirty code (I found on the internet) into Redmine to just add the rfc822 parts as attachments, but it would be nice to handle this correctly.

    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"

@ahorek
Copy link
Contributor

ahorek commented Jun 22, 2022

looks similar to my 2 year old PR :) #1389

@jcatrysse
Copy link
Author

Yes, indeed... it does! Any idea why this hasn't been merged / implemented?

And maybe more important... can this be implemented in for example a 2.7.2 version? I'm not that familiar with this :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants