2013-07-02 55 views
0

我正在使用谷歌電子表格存儲表單響應。有人工作了一點,但剛剛辭職,現在我收到郵件說我有這樣的錯誤:谷歌表單錯誤

Cannot find method (class)(class)sendEmail(string, string, string, string, object). (line 32, file "Code")

在我的電子表格中的第一列包含時間戳,那麼我的數據後馬上儲存。我已經粘貼下面我的代碼:

function onFormSubmit(e) { 
    var name = e.values[1]; 
    var department = e.values[2]; 
    var email = e.values[3]; 
    var phone = e.values[4]; 
    var project = e.values[5]; 
    var title = e.values[6]; 
    var description = e.values[7]; 
    var reach = e.values[8]; 
    var goal = e.values[9]; 
    var time = e.values[10]; 
    var work = e.values[11]; 


    // change this address to be the address where you want the notification to go 
    var to = "[email protected], [email protected]"; 
    var subject = "Intake Form Notification"; 
    var message = "Your Name: " + name + "\n \n"; 
     message += "Department: " + department + "\n \n"; 
     message += "Email: " + email + "\n \n"; 
     message += "Phone Number: " + phone + "\n \n"; 
     message += "Project title: " + title + "\n \n"; 
     message += "Project description: \n " + description + "\n \n"; 
     message += "Who are you trying to reach? \n" + reach + "\n \n"; 
     message += "Are you trying to achieve a specific goal with your communication efforts? \n" + goal + "\n \n"; 
     message += "Is this request time sensitive? \n " + time + "\n \n"; 
     message += "Are you currently working with someone in Marketing & Communications? \n" + work + "\n \n"; 
    var mailOptions = { 
     name: name, 
     replyTo: email, 
    }; 
MailApp.sendEmail(to, subject, message, mailOptions); 
} 

我的觸發設置爲OnFormSubmit >>從電子表格>>在表單提交

+1

您應該避免在互聯網上暴露真實的電子郵件地址,即使在SO上也是如此。 –

回答

1

我認爲這是一個小錯字。您是否可以刪除不需要的逗號mailOptions

var mailOptions = { 
     name: name, 
     replyTo: email //Removed comma 
    }; 
+0

謝謝你會嘗試一下 – dreamweaver

+0

這似乎已經修復了它。有時候會有一些延遲,但至少現在可以工作。謝謝。 – dreamweaver

+0

爲了記錄,發生此錯誤的原因是因爲在Javascript中創建「對象」時,鍵/值對應以逗號分隔,例如:'var myObject = {key1:val1,key2:val2}'。只要知道* last *元素後面不要加逗號。您的'對象'從未實例化,因爲這種錯字導致Google Apps腳本在您看到它時給您提供錯誤。也許你現在知道,也許不是! –