How to Convert MSG to JPG in Node.JS
MSG format is perfectly fine when you have Outlook on hand to deal with it, but this isn’t always practical, especially when dealing with large file quantities. MSG format has multiple challenges that need to be overcome before it can be dealt with. One problem is that MSG files can contain HTML, RTF, or even plain text, meaning we need three separate parsing methods. Then comes the matter of images and metadata. And finally, consider that after parsing, we still need to render and rasterize, and split this into a decent looking set of JPGs. What a mess. Well, I have a better idea. I can show you how to use an API that will handle all of this on its end, providing you with the results and none of the headache.
To begin, we must install the client:
npm install cloudmersive-convert-api-client --save
Now we have only to call this conversion function:
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 opts = {'quality': 56 // Number | Optional; Set the JPEG quality level; lowest quality is 1 (highest compression), highest quality (lowest compression) is 100; recommended value is 75. Default value is 75.};var callback = function(error, data, response) {if (error) {console.error(error);} else {console.log('API called successfully. Returned data: ' + data);}};apiInstance.convertDocumentMsgToJpg(inputFile, opts, callback);
Done! Just think of all the time you just saved.