I tried to send a customed HTML (+CSS) as PDF but the pdf sent turns out black and white. I hope someone helps me out, thanks :)
here is my function :
function sendEmails() {
var data = getBody("DATA");
var emailData = rowsToObjects(data);
emailData.forEach(function (rowObject) {
//var emailSubj = 'Konfirmasi Tagihan TUNEECA tanggal '+rowObject['TANGGAL AWAL']+' - '+rowObject['TANGGAL AKHIR']
const pdfhtml = HtmlService.createHtmlOutputFromFile('body-pdf').getContent();
const data = renderHtml(rowObject);
const htmlContent = pdfhtml.replace('hereismytabledata',data).replace('$CUSTNAME',rowObject['NAMA PARTNER']);
const blob = Utilities.newBlob(htmlContent, MimeType.HTML);
blob.setName('Rincian Tagihan.pdf');
var emailSubjectTemplate = 'Konfirmasi Tagihan tanggal {{TANGGAL AWAL}} - {{TANGGAL AKHIR}} ';
var emailBodyTemplate = HtmlService.createHtmlOutputFromFile('body-email').getContent();
var emailSubject = renderTemplate(emailSubjectTemplate, rowObject);
var body = renderTemplate(emailBodyTemplate, rowObject);
const recipientEmail = rowObject['EMAIL'];
console.log(emailSubject,body,recipientEmail)
MailApp.sendEmail({
to: recipientEmail,
subject: emailSubject,
htmlBody: body,
attachments: [blob.getAs(MimeType.PDF)],
});
});
}
and here is the result PDF sent by email:

ps : sorry i submit HTML as a picture during error when i tried to edit and add some codes.
