How to Convert EML to PNG in Node.js

Cloudmersive
2 min readOct 16, 2023

--

Converting EML files to PNG creates a static, lightweight copy of your file for long-term storage.

Using the below ready-to-run Node.js code, you can easily & conveniently convert EML files to PNG image arrays (one image per page of the original file) using a free API.

You can start by installing the SDK. Either run the following command:

npm install cloudmersive-convert-api-client --save

Or add the following snippet to your package.json:

  "dependencies": {
"cloudmersive-convert-api-client": "^2.6.3"
}

Now you can copy the below code examples into your file. First, however, you should get a free-tier API key to authorize your requests; these can be obtained on the Cloudmersive website and will allow up to 800 API calls per month with no commitments:

var CloudmersiveConvertApiClient = require('cloudmersive-convert-api-client');
var defaultClient = CloudmersiveConvertApiClient.ApiClient.instance;

// Configure API key authorization: Apikey
var Apikey = defaultClient.authentications['Apikey'];
Apikey.apiKey = 'YOUR API KEY';



var apiInstance = new CloudmersiveConvertApiClient.ConvertDocumentApi();

var inputFile = Buffer.from(fs.readFileSync("C:\\temp\\inputfile").buffer); // File | Input file to perform the operation on.


var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
apiInstance.convertDocumentEmlToPng(inputFile, callback);

That’s all there is to it — no more code required.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

No responses yet