Content-Disposition field missing in EML file. How do I treat this an an Attachment? - mime-types

I have an eml sample file which has an attachment but the content-disposition field is missing. The Microsoft Outlook treats the below mentioned body part as Attachment and displays the attachment file in the header field.
-----AU_MimePart_103082203221047146891954745
Content-Type: text/html;
charset=utf-8
Content-Transfer-Encoding: base64
//stream data
-----AU_MimePart_103082203221047146891954745--
How do I identify it as an attachment when the content-disposition filed is missing?

Related

How do I create a request in Swagger Inspector that accepts multiple data types?

I am currently trying to submit a request using the Swagger Inspector using multipart/form-data header to allow the submission of a file in conjunction with json data.
The JSON body of my request looks like:
And the headers with file upload look like:
For requests where I am just sending json to the server the Content-Type header is set to application/json and it is able to read from the body box. However I do not understand how this interface allows me to specify that the information coming from the body field is json and despite there being files on on the request.
I have seen requests that define multiple data types using the Conetent-Disspostion header, that look this this (reffenced from this Stack Overflow Post):
POST / HTTP/1.1
[[ Less interesting headers ... ]]
Content-Type: multipart/form-data; boundary=---------------------------735323031399963166993862150
Content-Length: 834
-----------------------------735323031399963166993862150
Content-Disposition: form-data; name="text1"
text default
-----------------------------735323031399963166993862150
Content-Disposition: form-data; name="text2"
aωb
-----------------------------735323031399963166993862150
Content-Disposition: form-data; name="file1"; filename="a.txt"
Content-Type: text/plain
Content of a.txt.
-----------------------------735323031399963166993862150
Content-Disposition: form-data; name="file2"; filename="a.html"
Content-Type: text/html
<!DOCTYPE html><title>Content of a.html.</title>
-----------------------------735323031399963166993862150
Content-Disposition: form-data; name="file3"; filename="binary"
Content-Type: application/octet-stream
aωb
-----------------------------735323031399963166993862150--
My question would be how do I create a request in swagger inspector that accepts multiple data types? It seems like I would need to set mulple sections in the body separated by boundaries with multiple Content-Disposition and Content-Type's for each. Would there be a cleaner way to do that through the Swagger Inspector interface? Or am I going about this in the wrong way?
Thanks!
Swagger Inspector currently supports multipart/form-data requests containing one or more files. It does not support arbitrary body parts in multipart requests (e.g. a file + JSON or text data). You'll need to use another HTTP client to test such requests.
You can submit feature request for Swagger Inspector here:
https://community.smartbear.com/t5/Swagger-Inspector-Feature/idb-p/SwaggerInspectorFeatureRequests

Export email to EML format which contains EML attachments

We are using Redemption from an Outlook addin for save messages to EML format (RFC822).
There was an unfortunate situation when one of out customer attached several EML file attachments into her email (and these emails were saved with Redemption).
The generated EML is not the same if I open in Outlook like the original message.
IMHO the issue caused by the fact the attached EML files using the same "00B0FEED_message_boundary" ID for message part boundaries.
I try to explain below:
... headers ..
Content-type: Multipart/mixed; charset=iso-8859-1;
boundary="00B0FEED_message_boundary"
Content-Description: Multipart message
--00B0FEED_message_boundary
Content-type: Multipart/alternative; charset=ISO-8859-1;
boundary="00B0FEEE_message_boundary"
Content-Description: Multipart message
--00B0FEEE_message_boundary
Content-type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Content-Description: Message text
... message body in plain text format ...
--00B0FEEE_message_boundary
Content-type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: Quoted-printable
Content-Disposition: inline
Content-Description: HTML text
... message body in HTML format ...
--00B0FEEE_message_boundary--
--00B0FEED_message_boundary
Content-type: application/octet-stream; charset=iso-8859-1;
name="=?iso-8859-1?Q?1=20Ab-=20und=20Zuschl=E4ge=2EEML?="
Content-Transfer-Encoding: Quoted-printable
Content-Disposition: attachment;
filename="=?iso-8859-1?Q?1=20Ab-=20und=20Zuschl=E4ge=2EEML?="
Content-Description: =?iso-8859-1?Q?1=20Ab-=20und=20Zuschl=E4ge=2EEML?=
... first attached message headers ...
Content-type: Multipart/mixed; charset=3Dutf-8;
boundary=3D"00B0FEED_message_boundary" <------ inner message boundary ID
Content-Description: Multipart message
--00B0FEED_message_boundary
Content-type: Multipart/related; charset=3DISO-8859-1;
boundary=3D"00B0FEEE_message_boundary"
Content-Description: Multipart message
--00B0FEEE_message_boundary
Content-type: Multipart/alternative; charset=3DISO-8859-1;
boundary=3D"00B0FEEF_message_boundary"
Content-Description: Multipart message
--00B0FEEF_message_boundary
Content-type: text/plain; charset=3Dutf-8
Content-Transfer-Encoding: Quoted-printable
Content-Disposition: inline
Content-Description: Message text
... first attached message body in plain text ...
--00B0FEEF_message_boundary
Content-type: text/html; charset=3Dutf-8
Content-Transfer-Encoding: Quoted-printable
Content-Disposition: inline
Content-Description: HTML text
... first attached message body in HTML ...
--00B0FEEF_message_boundary--
--00B0FEED_message_boundary--
--00B0FEED_message_boundary
... several other similar EML messages
This message not opening correctly in Outlook, but if I change the inner message boundary ID (and modify the corresponding part in the inner message) the EML opening correctly. So I presume this similar ID the cause of my issue.
Is there any workaround to force to use random ID for message boundary? Maybe to force to BASE64 encode the attachments?

Gmail API still replaces text/plain alternative body part with automatically generated one from HTML

I'm using GMail API to send a MIME email. The text part of the email always gets regenerated from the HTML part.
I have tried various variations in MIME and how I structure the headers. Another man reported the same problem a few years back:
Gmail API replaces text/plain alternative body part with automatically generated one from HTML
The message shows correctly in GMail interface "Sent" items, if I view the original of the message. However, the message arrives at the destination with text part replaced with HTML part. I tested it with several destinations, including Yahoo Mail.
The relevant part of the input multipart message is:
--0000000000d81f74059447a2ad02
Content-type: text/plain; charset=UTF-8
Hello plain text
--0000000000d81f74059447a2ad02
Content-type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<b>Hello html</b>
--0000000000d81f74059447a2ad02--
Viewing the raw message at the target (Yahoo Mail) shows this:
--00000000000046bd1105948482e9
Content-Type: multipart/alternative; boundary="00000000000046bd0e05948482e7"
--00000000000046bd0e05948482e7
Content-Type: text/plain; charset="UTF-8"
*Hello html*
--00000000000046bd0e05948482e7
Content-Type: text/html; charset="UTF-8"
<b>Hello html</b>
--00000000000046bd0e05948482e7--
Here's the full test case,
https://gist.github.com/borisreitman/448e2699c267221ebbf430b64346baaa
Notice that the text part now contains "Hello html" instead of the original "Hello plain text".
The proper syntax for the message composition is confusing
You need to past your plain text content BOTH in the text/plain and text/html part of the message.
Modify your code message body as following and it will work as a charm:
--0000000000d81f74059447a2ad02
Content-type: text/plain; charset=UTF-8
Hello plain text
*Hello html*
--0000000000d81f74059447a2ad02
Content-type: text/html; charset=UTF-8
<div dir="ltr">Hello plain text<br><div><br></div><div><b>Hello html</b><br></div></div>
--0000000000d81f74059447a2ad02--

The parsing of an eml with javamail doesn't recognize properly nested messages

I'm implementing an .eml parser using Javamail 1.5.6, I've started copying from msghow.java a sample provided within javamail.
I'm testing an eml which contains as attachment another eml, this is an extract:
MIME-Version: 1.0
Date: Tue, 30 Apr 2019 16:20:45 +0200
Message-ID: <CA+fLqEW8TUfSxih9DTp2WXa63pS7wf1eZiro_9k1XS4AShN5Zg#mail.gmail.com>
Subject: Message with an eml as attachment
From: a b <ab#gmail.com>
To: cd#pec.cd.it
Content-Type: multipart/mixed; boundary="00000000000057f76c0587c01bc9"
--00000000000057f76c0587c01bc9
Content-Type: multipart/alternative; boundary="00000000000057f7670587c01bc7"
--00000000000057f7670587c01bc7
Content-Type: text/plain; charset="UTF-8"
Hello guys,
this is a simple message from a not certified account, it contains only one
attachment, an eml message
--00000000000057f7670587c01bc7
Content-Type: text/html; charset="UTF-8"
<div dir="ltr">Hello guys,<div><br></div><div>this is a simple message from a not certified account, it contains only one attachment, an eml message</div></div>
--00000000000057f76c0587c01bc9
Content-Type: message/rfc822; name="Cena zerebao.eml"
Content-Disposition: attachment; filename="Cena zerebao.eml"
Content-Transfer-Encoding: base64
X-Attachment-Id: f_jv3vpu760
Content-ID: <f_jv3vpu760>
WC1Ob3Rlcy1JdGVtOiBGcmksIDYgSnVsIDIwMTggMTc6NDA6MDAgKzAyMDA7DQogdHlwZT00MDA7
IG5hbWU9T3JpZ2luYWxNb2RUaW1lDQpYLU5vdGVzLUl0ZW06IE1lbW87DQogbmFtZT1Gb3JtDQpY
LU5vdGVzLUl0ZW06IFN0ZE5vdGVzTHRyMjU7DQo.... and so on
Javamail recognizes that eml but when I get its subject, date, body, attachments and so on, they all are null.
msghow.java itself doesn't see them.
Before javamail I implemented my parser with mime4j and I haven't this problem, but now I would like to parse emls using only javamail if possible
From the javadocs describing the mail.mime.allowencodedmessages property:
The MIME spec does not allow body parts of type message/* to be encoded. The Content-Transfer-Encoding header is ignored in this case. Some versions of Microsoft Outlook will incorrectly encode message attachments. Setting this System property to "true" will cause the Content-Transfer-Encoding header to be honored for message attachments. The default value of this property is false.

multipart/mixed decryption on blackberry 10

I am writing an app that decrypts encrypted emails for a client.
The encrypted data is in the form of an email attachment, which, when decrypted, looks like this :
Content-Type: multipart/mixed;
boundary="PGP_Universal_830ECF7A_AFB087B4_241DE401_9BE7FFD1"
--PGP_Universal_830ECF7A_AFB087B4_241DE401_9BE7FFD1
Content-Type: multipart/alternative;
boundary="PGP_Universal_904F5C3F_3A8C9E07_A3A24D11_F0FB260C"
--PGP_Universal_904F5C3F_3A8C9E07_A3A24D11_F0FB260C
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7BIT
[snip]
--PGP_Universal_904F5C3F_3A8C9E07_A3A24D11_F0FB260C
Content-Type: text/html;
charset=us-ascii
Content-Transfer-Encoding: QUOTED-PRINTABLE
[html content]
--PGP_Universal_904F5C3F_3A8C9E07_A3A24D11_F0FB260C--
--PGP_Universal_830ECF7A_AFB087B4_241DE401_9BE7FFD1
Content-Type: application/pdf;
name="BB_FW_60_Manual_Key.Enrollment_Final_v1.pdf"
Content-Transfer-Encoding: BASE64
Content-Disposition: attachment;
filename="BB_FW_60_Manual_Key.Enrollment_Final_v1.pdf"
[base64 data]
--PGP_Universal_830ECF7A_AFB087B4_241DE401_9BE7FFD1--
I am writing the app in Cascades. As I cannot find a native way of transforming this data into an email, to let the email client deal with the attached base64-encoded file and so on, I am hoping to find a C++ class (it can optionally depend upon Qt, obviously) that I can use on the BB10 which can parse these kind of multipart messages.
It is possible to get SPMIME to compile on BB10. It is LGPL so it might need to be compiled seperately and linked to if your app is not GPL.

Resources