I don't know whether it will work for you or not, I was using SendGrid. And this is how I did.
I first utilize the html-pdf-node npm package to generate pdfBuffer out of HTML code.
let file = { content: emailTemplate };
let options = { format: "A4" };
const pdfBuffer = await html_to_pdf.generatePdf(file, options);
And then, SENDGRID.send method to basically send an email, with body content and pdf as an attachment
await SENDGRID.send({
from,
to,
html,
subject,
attachments: [
{
content: pdfBuffer.toString("base64"),
filename: filename,
type: "application/pdf",
disposition: "attachment",
},
],
});
Properties I passed above are:
From(email) - from whom
to(email) - to whom
html - the body content as an HTML code
subject - email subject
filename - filename of the attachment e.g. my_file.pdf
I hope it will help :)