最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Opening and viewing Eml files in Html - Stack Overflow

programmeradmin1浏览0评论

I am trying to create a JS script to open and view Eml file. But till now I am stuck and with no way to go further. Can someone give me some directions. I was planning to post back my findings here with code so others can benefit too.

I am trying to create a JS script to open and view Eml file. But till now I am stuck and with no way to go further. Can someone give me some directions. I was planning to post back my findings here with code so others can benefit too.

Share asked Oct 12, 2014 at 14:08 esafwanesafwan 18.1k35 gold badges110 silver badges170 bronze badges 1
  • I'm interested in that question too. In the meantime, I suggest using mhonarc to convert (on the server) the eml files to html. – Clément Commented Nov 20, 2017 at 2:31
Add a ment  | 

1 Answer 1

Reset to default 1

The first step is to load the EML file either as a String or as a Stream. A EML file should look like this:

Date: Wed, 29 Jan 2014 11:10:06 +0100
To: "Foo Bar" <[email protected]>
From: Online Shop <[email protected]>
Subject: Winter promotions
Content-Type: text/plain; charset=utf-8

Some Content

If you are looking to parse it yourself you have to look for keys like this:

/[\n\r]+[\-a-zA-Z]+:/      (a newline followed by a word with no spaces and a colon)

Everything after the colon and before the next key will bee the value for that key.

  • However bear in mind that keys will repeat and the order they appear matters,
  • Some keys are optional and most eml you will find nowadays have plenty of custom Keys,
  • You should double check the values as some will need a decode algorithm to be usable.

If you want to learn more about it you may look into these:

  • ver 822: http://www.ietf/rfc/rfc0822.txt
  • ver 1521: https://www.ietf/rfc/rfc1521.txt

If you want some working code ready to use you may look here:

  • https://www.npmjs./package/eml-format
发布评论

评论列表(0)

  1. 暂无评论