这个脚本工作正常,直到今天我将cc和bcc变量添加到自动电子邮件脚本中。现在,我收到了收件人电子邮件地址的错误,我想我的选项cc和bcc的对象也有问题。错误是无效的电子邮件地址,有和没有cc和密件抄送。也就是说,不知怎的,我打破了脚本,甚至旧版本都无法正常工作 - 谷歌更新了什么?非常感谢任何帮助。
function sendEmails1() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
ss.setActiveSheet(ss.getSheetByName("Send-Emails"));
var sheet = SpreadsheetApp.getActiveSheet();
var dataRange = sheet.getRange("A2:O10");
var data = dataRange.getValues();
for (i in data) {
var rowData = data[i];
var build = rowData[0];
var emailAddress1 = rowData[1];
var emailAddress2 = rowData[2];
var emailAddress3 = rowData[3];
var emailAddress4 = rowData[4];
var cc1 = rowData[11];
var cc2 = rowData[12];
var bcc1 = rowData[13];
var bcc2 = rowData[14];
var options = {
cc: "'" + cc1 + "," + cc2 + "'" ,
bcc: "'" + bcc1 + "," + bcc2 + "'"
}
var recipient = rowData[5];
var text2 = rowData[6];
var signoff = 'text';
var message = recipient + ', ' + text2 + signoff + '\n\n' + sender;
var subject = 'text';
//prompt the user with the composed email for review
var confirm = Browser.msgBox('Send the following email?', 'text', Browser.Buttons.YES_NO);
if(confirm === 'yes'){
MailApp.sendEmail(emailAddress1 + "," + emailAddress2 + "," + emailAddress3 + "," + emailAddress4, subject, message, options);
}
答案 0 :(得分:0)
我的没有接收器的草稿写入脚本有同样的问题,当单元格为空时返回一个未定义的错误。我在空白单元格的测试中写道,如果是这样的话,请将' null'在参数中。现在我的脚本工作了:
if(recipient==""){GmailApp.createDraft(null, sub, null, {cc: seesee, bcc:
beeseesee, htmlBody: body1});}
else{
GmailApp.createDraft(recipient, sub,null, {cc: seesee, bcc: beeseesee,
htmlBody: body1}); }
如果收件人,seesee,sub,body1和beeseesee是我的变量。
答案 1 :(得分:0)
Google脚本中的此代码脚本有助于通过cc在Gmail中创建电子邮件草稿,因此希望对某人有所帮助。
function myFunction() {
// The code below creates a draft email with the current date and time.
var now = new Date();
var ccmail = "dummy@gmail.com"
GmailApp.createDraft("main@gmail.com,", "current time", "The time is: " +
now.toString(), {cc: ccmail} );
}