提交时的Google表单电子邮件通知

时间:2014-07-14 22:12:19

标签: email google-apps-script google-form

我试图更新此脚本以允许我更新发件人""或"回复"电子邮件地址。我不确定如何使用此处列出的脚本 - http://www.labnol.org/?p=20884

我已通过电子邮件通知此脚本的开发者,但尚未收到回复。有关添加字段以覆盖默认值的任何建议"回复"或发件人电子邮件地址?

感谢您的帮助!

/* Send Google Form by Email v2.0 */
    /* For customization, contact the developer at amit@labnol.org */
    /* Tutorial: http://www.labnol.org/?p=20884 */
    function Initialize() {
    var triggers = ScriptApp.getScriptTriggers();
    for(var i in triggers) {
    ScriptApp.deleteTrigger(triggers[i]);
    }
    ScriptApp.newTrigger("SendGoogleForm")
    .forSpreadsheet(SpreadsheetApp.getActiveSpreadsheet())
    .onFormSubmit()
    .create();
    }
    function SendGoogleForm(e)
    {
    try
    {
    // You may replace this with another email address
    var email = "CLIENT EMAIL ADDRESS";
    // Optional but change the following variable
    // to have a custom subject for Google Form email notifications
    var subject = "Form Application Submitted";
    var s = SpreadsheetApp.getActiveSheet();
    var columns = s.getRange(1,1,1,s.getLastColumn()).getValues()[0];
    var message = "";
    // Only include form fields that are not blank
    for ( var keys in columns ) {
    var key = columns[keys];
    if ( e.namedValues[key] && (e.namedValues[key] != "") ) {
    message += key + ' :: '+ e.namedValues[key] + "\n\n";
    }
    }
    // This is the MailApp service of Google Apps Script
    // that sends the email. You can also use GmailApp for HTML Mail.
    MailApp.sendEmail(email, subject, message);
    } catch (e) {
    Logger.log(e.toString());
    }
    }

1 个答案:

答案 0 :(得分:0)

替换

MailApp.sendEmail(email, subject, message);

GmailApp.sendEmail(email, subject, message, {replyTo: "abc@example.com", from: "xyz@example.com"});

来自地址必须是别名。