2016-09-22 86 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帳戶關聯。仔細觀察我的腳本,其中大約一半已經失去了訪問權限,但有一半仍然正常工作。謝謝! –