【发布时间】:2020-09-17 03:39:36
【问题描述】:
我有一个项目,我需要批量发送一封电子邮件,其中包含特定于每个用户的文本,以及来自关联 gmail 帐户的签名和图像。我有这个自动取款机:
//get template/draft email & body
const scGmailTemplate = GmailApp.getDraft("r4329894329375089160");
const scGmailTemplateMessage = scGmailTemplate.getMessage();
const scGmailTemplateBody = scGmailTemplateMessage.getBody();
//create new gmail
let scGmailContactMessageBody = scGmailTemplateBody;
//create array for gmail find & replaces [find, replace]
const gmailFindReplace = [["INV_START", scVars.INV_START],
["INV_END", scVars.INV_END],
["DEM_DATE", scVars.DEM_DATE]
];
gmailFindReplace.forEach(x=>{scGmailContactMessageBody=scGmailContactMessageBody.replace(x[0], x[1])});
const scGmailSubject = "Service Charge Invoice ("+scVars.INV_START+"-"+scVars.INV_END+")";
let bodyHtml = HtmlService.createHtmlOutput(scGmailContactMessageBody);//didnt work
GmailApp.sendEmail("me@me.com", "test", scGmailContactMessageBody);
问题是生成的电子邮件只是原始 html,图像显示在底部
我尝试添加{htmlBody: html} 作为选项,但会引发错误html not defined。
任何帮助将不胜感激
【问题讨论】:
标签: javascript google-apps-script