问题描述
我有一个使用以下脚本的脚本:
MailApp.sendEmail(row.shiftManager,假期批准请求,,{htmlBody:message});
row.state = STATE_PENDING;
然而,我也想发送相同的邮件到 row.shiftSupervisor
,这可能是一件非常简单的事情,我忽略了,但我想到这里的某人会立即知道是什么。
为你的帮助:)
修改 - 我尝试使用:
MailApp.sendEmail(row.shiftManager,row.shiftSupervisor,假期批准请求,,{htmlBody:message});
row.state = STATE_PENDING;
但没有欢乐。
编辑2 - 我使用它:
MailApp.sendEmail(row.shiftManager,假期批准请求,,{htmlBody:message});
MailApp.sendEmail(row.shiftSupervisor,假期批准请求,,{htmlBody:message});
row.state = STATE_PENDING;
不是最优美的代码片段,但它做的工作...
编辑3 - 查看Sandy的解决方案后,我认为是格式化。
Sandy的解决方案工作正常,但与我的脚本的其他部分引起冲突。所以我的解决方案是:
MailApp.sendEmail(row.shiftManager +,+ row.shiftSupervisor,假期批准请求 ,,{htmlBody:message});
一种解决方案是以这种方式配置语法: / p>
MailApp.sendEmail(row.shiftManager +,+ row.shiftSupervisor,假期批准请求,,{htmlBody : 信息});
另一种方法是首先将多个电子邮件地址置入变量,然后使用以下语法: p>
MailApp.sendEmail({
to:recipientsTO,
cc:recipientsCC,
主题:主题,
htmlBody:html
});
完整的代码将是:
function sendToMultiple(){
var message =这是HTML< br>< br>第二行的测试;
var recipientsTO =example@gmail.com+,+example@yahoo.com;
var recipientsCC =example@gmail.com;
var Subject =假期批准请求;
var html = message;
MailApp.sendEmail({
to:recipientsTO,
cc:recipientsCC,
主题:主题,
htmlBody:html
}) ;
}
该链接显示了一个示例中的语法: / p>
I have a script that is using the following script:
MailApp.sendEmail(row.shiftManager, "Holiday Approval Request", "", {htmlBody: message});
row.state = STATE_PENDING;
Howeverm I would like to also send the same mail to row.shiftSupervisor
, this is probably something really simple that I've overlooked, but I figured someone here would know straight away what it was.
Cheers for your help :)
Edit - I tried to use:
MailApp.sendEmail(row.shiftManager, row.shiftSupervisor, "Holiday Approval Request", "", {htmlBody: message});
row.state = STATE_PENDING;
But no joy.
Edit 2 - I got it working with:
MailApp.sendEmail(row.shiftManager, "Holiday Approval Request", "", {htmlBody: message});
MailApp.sendEmail(row.shiftSupervisor, "Holiday Approval Request", "", {htmlBody: message});
row.state = STATE_PENDING;
Not the most graceful looking piece of code, but it does the job...
Edit 3 - After looking at Sandy's solution, I figured it was formatting.Sandy' solution works fine, but caused conflicts with some other parts of my script. So my solution was:
MailApp.sendEmail(row.shiftManager + "," + row.shiftSupervisor, "Holiday Approval Request", "", {htmlBody: message});
One solution is to configure the syntax this way:
MailApp.sendEmail(row.shiftManager + "," + row.shiftSupervisor, "Holiday Approval Request", "", {htmlBody: message});
Another method is to put the multiple email addresses into a variable first, then use this syntax:
MailApp.sendEmail({
to: recipientsTO,
cc: recipientsCC,
subject: Subject,
htmlBody: html
});
The complete code would be:
function sendToMultiple() {
var message = "This is a test of HTML <br><br> Line two";
var recipientsTO = "example@gmail.com" + "," + "example@yahoo.com";
var recipientsCC = "example@gmail.com";
var Subject = "Holiday Approval Request";
var html = message;
MailApp.sendEmail({
to: recipientsTO,
cc: recipientsCC,
subject: Subject,
htmlBody: html
});
}
That syntax is shown in an example at this link:
Google Documentation - MailApp.sendEmail
这篇关于Google脚本:MailApp.sendEmail到多个地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!