本文介绍了如何在Google App脚本中向多个收件人发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我无法通过Google脚本发送电子邮件以增加地址
I am unable to send email through google script to multiply addresses
尝试使用GmailApp.sendEmail,MailApp.SendEmail,var收件人= testmail + chemAmail;.
Tried with GmailApp.sendEmail,MailApp.SendEmail, var recipient = testmail + chemAmail ;.
var testmail = "[email protected]" ;
var chemAmail = "[email protected]" ;
var body = "Hi,<br><br>" +
"This is a Quality Alert.Please brief the required people and submit the Briefing Record EForm when it is completed." + "<br><br>" +
"The details are stated below :<br>" +
"Customer: " + customer + "<br>" +
"Part Number: " + part + "<br>" +
"S Number: " + s + "<br>" +
"ID Number: " + id + "<br>" +
"Defect : " + defect + "<br>" +
"Description : " + desc + "<br>" +
"Reject Photos : " + reject + "<br>" +
"Okay Photos : " + ok + "<br><br>" +
"Please complete it as soon as possible." + "<br><br>" +
"Thanks." ;
// Sends if chemA is ticked (Conditions for email to be sent)
if(chemA == '✔')
{
var recipient = testmail , chemAmail;
var subject = "Quality Alert for Chem A";
}
GmailApp.sendEmail(recipient, subject, " ",{htmlBody: body});
我只能将其发送到testmail.我希望能够发送到多个电子邮件地址.
I can send it to testmail only. I want to be able to send to multiple email addresses.
推荐答案
- 您要将邮件发送到多个邮件地址.
如果我的理解是正确的,那么该修改如何?
If my understanding is correct, how about this modification?
var recipient = testmail , chemAmail;
收件人:
var recipient = [testmail, chemAmail];
注意:
- 在我的环境中,我正在使用上述方法.但是我找不到官方文档,因此,如果在您的环境中无法正常工作,我深表歉意.
- 通过,我可以在 GmailApp.sendEmail().
- 通过这种方式,数组可以通过
array.join(",")
之类的脚本转换为字符串. - In my environment, I'm using above method. But I couldn't find the official document, so if this didn't work in your environment, I apologize.
- By TheMaster's comment, I could find the description of
comma separated list of email addresses
at GmailApp.sendEmail().- By this, the array might be converted to the string by the script like
array.join(",")
.
- By this, the array might be converted to the string by the script like
- By TheMaster's comment, I could find the description of
Note:
- 通过这种方式,数组可以通过
- 通过,我可以在 GmailApp.sendEmail().