Google Apps脚本失去了访问权限

时间:2016-09-22 01:09:11

标签: email google-apps-script

我有一个Google表格脚本,可在提交表单时通过电子邮件向一组人发送通知。它工作了好几个月。现在它似乎失去了发送电子邮件的访问权限。 2015年11月6日是最后一次提交回复并成功通过电子邮件发送的回复。直到昨天(2016年9月21日)才提交更多回复,并且它不再有权发送电子邮件。我确认它未在我的“与您的帐户关联的应用”下的Google帐户的安全部分中列出。

我试图通过删除所有触发器来保存和关闭脚本来重新授权它。然后我重新打开它并重新添加了触发器。它没有要求新的授权,但它仍然不会发送电子邮件。

  1. 有谁知道为什么它可能会失去访问权限?如果没有定期使用它会被删除吗?
  2. 如何强制刷新/续订权利?或者我只需要完全删除脚本并重新创建一个新副本?
  3. 这只是我所拥有的许多类似脚本中的一个,我需要弄清楚如何使它们工作(并保持它们正常工作)。搜索我除了如何故意撤销访问权限之外找不到任何东西。

    这是我的代码,所以你可以看到它正在尝试做什么(我现在只用我的电子邮件地址测试它)。我承认我对编程脚本知之甚少,所以它可能不是很漂亮。

    感谢您的帮助!

    function sendFormByEmail(e)
    {
    // Remember to replace this email address with your own email address
    var email = "bjwarneke@gmail.com";
    var quiz = "02.8-JLOT-D Drop-In";
    var filename = "02-JLOT Exam Grading Instructions";
    
    var s = SpreadsheetApp.getActiveSheet();
    var headers = s.getRange(1,1,1,s.getLastColumn()).getValues()[0];
    var message = "Time for someone to go grade a quiz from me!" + "<br>";
    var replyto = e.namedValues[headers[1]].toString();
    var subject = 'Quiz: ' + replyto;
    
    //message += headers[1] + ': '+ e.namedValues[headers[1]].toString() + "\n";
    //message += headers[0] + ': '+ e.namedValues[headers[0]].toString() + "\n";
    message += headers[1] + ': '+ e.namedValues[headers[1]].toString() + "<br>";
    message += headers[0] + ': '+ e.namedValues[headers[0]].toString() + "<br><br>";
    
    message += quiz + "<br>";
    message += '<a href="'+link+'">'+filename+'</a><br>';
    
    
    // The variable e holds all the form values in an array.
    // Loop through the array and append values to the body.
    
    //for(var i in headers)
    //message += headers[i] + ': '+ e.namedValues[headers[i]].toString() + "\n\n";
    // Insert variables from the spreadsheet into the subject.
    // In this case, I wanted the new hire's name and start date as part of the
    // email subject. These are the 3rd and 16th columns in my form.
    // This creates an email subject like "New Hire: Jane Doe - starts 4/23/2013"
    //subject += e.namedValues[headers[2]].toString() + " - starts " + e.namedValues[headers[15]].toString();
    
    // Send the email
      MailApp.sendEmail(email, subject, message, {htmlBody:message, name:"Quiz", replyTo:replyto});
    
    // Based off of a script originally posted by Amit Agarwal - www.labnol.org
    // Credit to Henrique Abreu for fixing the sort order
    }
    

1 个答案:

答案 0 :(得分:1)

您是否拥有与您的Google帐户关联的Gmail帐户?只有在您的帐户启用了Gmail后,MailApp服务才会生效。

相关问题