email - 如何将当前用户的电子邮件地址传递给 Google Script

标签 email google-apps-script google-sheets carbon-copy

我在 Google 电子表格后面有一个脚本,它会在完成某行的某些单元格后发送一封电子邮件。该脚本通过发送到多个硬编码电子邮件地址来工作。如何将当前用户的电子邮件地址添加为第二个抄送?其中一个 CC 是硬编码的,但第二个 CC 根据更新电子表格的人而变化。我知道如何获取电子邮件地址,但如何将其作为变量传递,以便它实际上被抄送?

var currentemail = Session.getActiveUser().getEmail();

var options = {cc: 'Session.getActiveUser().getEmail(), someotheremail@domain.com'}; 

var options = {cc: 'currentemail, someotheremail@domain.com'};

GmailApp.sendEmail(email, subject, body, options);

显然这些不起作用:)

提前致谢

最佳答案

这可以像下面这样完成:

function sendWithCc(){
   var currentemail = Session.getActiveUser().getEmail();
   var options = {};// create object
   options['cc'] = currentemail+',someotheremail@domain.com';// add key & values (comma separated in a string)
   GmailApp.sendEmail('somemail@domain.com', 'subject', 'body', options);
   // I stringified 'subject' and 'body' to make that test work without defining values for it
}

关于email - 如何将当前用户的电子邮件地址传递给 Google Script,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26411395/

相关文章:

java - Gmail 不会发送从应用程序推送的电子邮件附件

VBA 跟踪文件使用情况

java - 无法连接到 SMTP 主机 : x. x.x.x,端口:java 中的 25

google-apps-script - 如何使用 Google Apps Docs Script 将光标移动到插入文本的末尾?

javascript - 如何在 javascript 字符串中插入一个新段落?

javascript - 如何将变量传递给函数

javascript - GAS 找到所有匹配的值,然后通过电子邮件将它们一起发送

python - 在 Python 中从 HTML 中抓取嵌入的 Google Sheet

email - Amazon SES 最大发送速率

javascript - Google Apps 脚本获取错误的持续时间值