如何解决如何在 Google Apps Script 中为主题行添加抄送、定制发件人姓名和获取数据? 答案:示例:参考:
我是 Google Apps 脚本的新手。我想知道如何在此脚本中添加抄送?
同时,当发送电子邮件时,接收者会看到我的名字(例如 peter.henderson),如果我将其更改为 Peter Henderson 可以吗?
对于主题行,我想获取人们的姓名。所以这将类似于“感谢您的关注,NAME!”我该怎么做?
谢谢!
function onFormSubmit(e) {
var whatisyourname = e.values[2];
var email = e.values[1];
var template = HtmlService.createTemplateFromFile("followupemailtemplate");
template.name = whatisyourname;
template.evaluate
MailApp.sendEmail(email,"Thank you for your interest!","",{htmlBody: template.evaluate().getContent() });
}
解决方法
答案:
使用高级参数 name
设置发件人姓名,cc
将某人抄送给电子邮件,使用模板文字将输入的姓名插入主题。
示例:
function onFormSubmit(e) {
const email = e.values[1]
const name = e.values[2]
const subject = `Thank you for your interest,${name}`
const body = "Some non-HTML body content"
var template = HtmlService.createTemplateFromFile("followupemailtemplate")
template.name = name
template.evaluate()
const options = {
htmlBody: template.getContent(),cc: "[email protected]",name: "Peter Henderson"
}
MailApp.sendEmail(email,subject,body,options)
}
参考:
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。