How to Convert EML to PNG in Node.JS

Converting EML files is a difficult process under the best of circumstances. The task is made more difficult still when working in Node.JS. Thankfully, there is an easier solution that I have in mind, one that will handle all of the parsing of HTML, rendering, etc. To do this, we have only but to set up a function call for an API. Let’s look at how this is set up.

First is our client installation.

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

Now the function call:

var CloudmersiveConvertApiClient = require('cloudmersive-convert-api-client');var defaultClient = CloudmersiveConvertApiClient.ApiClient.instance;// Configure API key authorization: Apikeyvar Apikey = defaultClient.authentications['Apikey'];Apikey.apiKey = 'YOUR API KEY';// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)//Apikey.apiKeyPrefix = 'Token';var apiInstance = new CloudmersiveConvertApiClient.ConvertDocumentApi();var inputFile = "/path/to/file"; // 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);

And finally… well that’s it, really. For more lightning-fast solutions like this, check out the documentation section for more on this library.

Image for post
Image for post

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store