2016-09-22 84 views
0

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

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

  1. 有谁知道为什么它可能会失去访问权限?如果没有定期使用,它会被删除吗?
  2. 我该如何强制刷新/更新权限?或者我只需要完全删除脚本并重新创建一个副本?

这只是我有很多类似的脚本之一,我需要弄清楚如何使它们工作(并保持它们的工作)。在我周围搜索找不到任何东西,除了如何故意撤销访问权限。

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

感谢您的帮助!

function sendFormByEmail(e) 
{ 
// Remember to replace this email address with your own email address 
var email = "[email protected]"; 
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

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

+0

是的,我确实有一个Gmail帐户关联。仔细观察我的脚本,其中大约一半已经失去了访问权限,但有一半仍然正常工作。谢谢! –