We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

MailMerge basics

I am just trying out the asposewordscloud npm package for the first time, specifically the mail merge feature. I am able to successfully call the service and get a response, but I don’t understand how to read the response. I tried saving the response body as a file, but it just contains the template, not the finished, merged output. Here is my code:

const wordsApi = new WordsApi(clientId, secret);

let requestTemplate = fs.createReadStream("TestExecuteTemplate.doc");
let requestData = fs.createReadStream("TestExecuteTemplateData.xml");

const mailMergeRequest = new ExecuteMailMergeOnlineRequest({
    template: requestTemplate,
    data: requestData
});

wordsApi.executeMailMergeOnline(mailMergeRequest)
.then((mailMergeRequestResult) => {
   fs.writeFile('output.doc', mailMergeRequestResult.body, function (err) {
        if (err) return console.log(err);
         // tslint:disable-next-line:no-console
        console.log('saved file');
      });
});

Why doesn’t mailMergeRequestResult.body contain the merged output? Where is it?

Thanks, Dan

This topic has been moved to the related forum: https://forum.aspose.cloud/t/mailmerge-basics/8247