Last active
March 22, 2022 18:36
-
-
Save FrancoMuniz/4a37c3f8b8a7a91d6e4ed68202ae0330 to your computer and use it in GitHub Desktop.
Convert EML to HTML
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const simpleParser = require('mailparser').simpleParser; //Remember to do npm install mailparser | |
const myFile = "myEmail.eml" // Replace this with your .eml file | |
var eml = fs.readFileSync(myFile, "utf-8"); | |
simpleParser(eml).then(parsed => { | |
htmlFile = parsed["html"] | |
htmlFile = htmlFile.replace(/\\r/g, ''); //This removes all "\r" | |
htmlFile = htmlFile.replace(/\\n/g, ''); //This removes all "\n" | |
htmlFile = htmlFile.replace(/\\/g, ''); //This removes all "\" | |
fs.writeFileSync("emailHtml.html", htmlFile); //Here's your HTML file. You can change the name if you wish | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Requirements:
npm install mailparser