papnkukn / eml-format

RFC 822 EML file format parser and builder
MIT License
88 stars 53 forks source link

html, text, and attachments not parsed correctly #5

Closed ruscles closed 6 years ago

ruscles commented 6 years ago

Hi,

I have tried parsing multiple .eml files and the html, text, and attachment data always appear in the "attachments" array of the data response instead of individual key-value pairs.

"attachments": [
    {
      "data": "> This message is in MIME format. Since your mail reader does not understand\r\nthis format, some or all of this message may not be legible.\r\n\r\n--B_3154931329_1876711415\r\nContent-type: multipart/alternative;\r\n\tboundary=\"B_3614931529_162566274\"\r\n\r\n\r\n--B_3154931329_162566274\r\nContent-type: text/plain;\r\n\tcharset=\"UTF-8\"\r\nContent-transfer-encoding: 7bit\r\n\r\nplease see attached \r\n\r\n\r\ntest\r\ntest\r\n804-314-1416\r\n\r\n\r\n--B_3611531329_162566274\r\nContent-type: text/html;\r\n\tcharset=\"UTF-8\"\r\nContent-transfer-encoding: quoted-printable\r\n\r\n<html>\r\n<head>\r\n<meta http-equiv=3D\"Content-Type\" content=3D\"text/html; charset=3Dutf-8\">\r\n</head>\r\n<body>\r\n<div dir=3D\"ltr\">please see attached\r\n<div><br>\r\n</div>\r\n<div><br clear=3D\"all\">\r\n<div>\r\n<div dir=3D\"ltr\" class=3D\"gmail_signature\" data-smartmail=3D\"gmail_signature\">\r\n<div dir=3D\"ltr\">test<br>\r\test<br>\r\n804-314-1416</div>\r\n</div>\r\n</div>\r\n</div>\r\n</div>\r\n</body>\r\n</html>\r\n\r\n\r\n--B_3614931329_162515274--\r\n\r\n\r\n--B_3611531329_1876711415\r\nContent-type: image/png; name=\"file.png\";\r\n x-mac-creator=\"4F50494D\";\r\n x-mac-type=\"504E4766\"\r\nContent-ID: <f_jjeyqso90>\r\nContent-disposition: attachment;\r\n\tfilename=\"file.png\"\r\nContent-transfer-encoding: base64\r\n\r\niVBORw0KGgoAAAANSUhEUgAABQAAAALQCAIAAABAH0oBAACAAElEQVR4......
     }
]

Is there way to parse these items out individually into the result json?

ruscles commented 6 years ago

Started working after a fresh npm install