How to Convert EML to PDF in JavaScript

Cloudmersive
1 min readJul 14, 2021

--

The EML format has the capacity to display the entire contents of an email, including attachments, body text, and sender fields. However, if you need to share the file with other individuals, it may be a good idea to switch it over to the display-friendly PDF format. To simplify the often-complicated conversion process, we will be demonstrating an API solution that can be used in JavaScript to automatically convert EML to PDF.

Let’s kick this quick operation off by running this command to install jQuery:

bower install jquery

Once the installation is complete, we can call the function with the following example code:

var form = new FormData();
form.append("inputFile", fileInput.files[0], "file");
var settings = {
"url": "https://api.cloudmersive.com/convert/eml/to/pdf",
"method": "POST",
"timeout": 0,
"headers": {
"bodyOnly": "<boolean>",
"Content-Type": "multipart/form-data",
"Apikey": "YOUR-API-KEY-HERE"
},
"processData": false,
"mimeType": "multipart/form-data",
"contentType": false,
"data": form
};
$.ajax(settings).done(function (response) {
console.log(response);
});

Your new PDF file will be ready in seconds flat. To retrieve an API key, head to the Cloudmersive website to register for a free account; this provides 800 calls/month across our library of APIs.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

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

No responses yet