Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google apps script 要从alias发送确认电子邮件吗_Google Apps Script_Google Forms - Fatal编程技术网

Google apps script 要从alias发送确认电子邮件吗

Google apps script 要从alias发送确认电子邮件吗,google-apps-script,google-forms,Google Apps Script,Google Forms,我希望我的确认电子邮件的“发件人”地址来自一个别名帐户,而不是我默认的谷歌帐户 这是我的密码。我已尝试替换cc=Session.getActiveUser().getEmail()使用别名电子邮件地址,但这不起作用 /* Send Confirmation Email with Google Forms */ function Initialize() { var triggers = ScriptApp.getProjectTriggers(); for (var i i

我希望我的确认电子邮件的“发件人”地址来自一个别名帐户,而不是我默认的谷歌帐户

这是我的密码。我已尝试替换
cc=Session.getActiveUser().getEmail()使用别名电子邮件地址,但这不起作用

/* Send Confirmation Email with Google Forms */

function Initialize() {

    var triggers = ScriptApp.getProjectTriggers();

    for (var i in triggers) {
        ScriptApp.deleteTrigger(triggers[i]);
    }

    ScriptApp.newTrigger("SendConfirmationMail")
        .forSpreadsheet(SpreadsheetApp.getActiveSpreadsheet())
        .onFormSubmit()
        .create();

}

function SendConfirmationMail(e) {

    try {

        var ss, cc, sendername, subject, columns;
        var message, value, textbody, sender;

        // This is your email address and you will be in the CC
        cc = Session.getActiveUser().getEmail();

        // This will show up as the sender's name
        sendername = "EarthFest Singapore";

        // Optional but change the following variable
        // to have a custom subject for Google Docs emails
      subject = "EarthFest Tickets";

        // This is the body of the auto-reply
      message = "<center><img src='http://earthfestsingapore.com/email_logo.png' /></center><br><center>Tickets for Sept. 26, 2015.  10:30 am to 3:30 pm.</center><br>Thanks so much for joining EarthFest!  Let's make a modern and sustainable future fun, delicious, and possible!<br><br>We can't wait to see you there!  Feel free to invite your friends by sharing this link: <a href='http://goo.gl/mS5D2X'>http://goo.gl/mS5D2X</a> and we'd love to see you on:<br><br><center><a href='http://facebook.com/earthfestsingapore'><img src='http://earthfestsingapore.com/facebook_small.png' /></a>&nbsp;&nbsp;<a href='http://instagram.com/earthfestsing'><img src='http://earthfestsingapore.com/instagram_small.png' /></a>&nbsp;&nbsp;<a href='http://twitter.com/earthfestsing'><img src='http://earthfestsingapore.com/twitter_small.png' /></a>&nbsp;&nbsp;<a href='https://www.youtube.com/user/earthfestsing'><img src='http://earthfestsingapore.com/youtube_small.png' /></a></center><br><br>";

        ss = SpreadsheetApp.getActiveSheet();
        columns = ss.getRange(1, 1, 1, ss.getLastColumn()).getValues()[0];

        // This is the submitter's email address
        sender = e.namedValues["E-mail address can we send tickets"].toString();

        // Only include form values that are not blank
        for ( var keys in columns ) {
            var key = columns[keys];
            if ( e.namedValues[key] ) {
                message += key + ' :: '+ e.namedValues[key] + "<br />"; 
            }
        }

        textbody = message.replace("<br>", "\n");

        GmailApp.sendEmail(sender, subject, textbody, 
                            {cc: cc, name: sendername, htmlBody: message});

    } catch (e) {
        Logger.log(e.toString());
    }

}
/*使用谷歌表单发送确认电子邮件*/
函数初始化(){
var triggers=ScriptApp.getProjectTriggers();
for(触发器中的var i){
ScriptApp.deleteTrigger(触发器[i]);
}
ScriptApp.newTrigger(“发送确认邮件”)
.forSpreadsheet(SpreadsheetApp.getActiveSpreadsheet())
.onFormSubmit()
.create();
}
功能SendConfirmationMail(电子邮件){
试一试{
变量ss、cc、发送者名称、主题、列;
var消息、值、文本体、发送方;
//这是您的电子邮件地址,您将进入CC
cc=Session.getActiveUser().getEmail();
//这将显示为发件人的名称
sendername=“新加坡地球节”;
//可选,但更改以下变量
//为谷歌文档电子邮件设置自定义主题
主题=“地球节门票”;
//这是自动回复的主体
message=“
2015年9月26日的门票。上午10:30至下午3:30。
非常感谢您加入EarthFest!让我们让一个现代和可持续的未来变得有趣、美味和可能!

我们迫不及待地想在那里见到您!欢迎通过共享此链接邀请您的朋友:我们很高兴在:




上看到您; ss=电子表格app.getActiveSheet(); columns=ss.getRange(1,1,1,ss.getLastColumn()).getValues()[0]; //这是提交者的电子邮件地址 sender=e.namedValues[“我们可以发送票证的电子邮件地址”]。toString(); //仅包括非空的表单值 for(列中的变量键){ var key=列[键]; 如果(例如,名称值[键]){ message+=key+::“+e.namedValues[key]+”
”; } } textbody=message.replace(“
”,“\n”); GmailApp.sendmail(发件人、主题、正文、, {cc:cc,name:sendername,htmlBody:message}); }捕获(e){ Logger.log(例如toString()); } }
您可以在sendmail()方法的options参数中添加别名


嗨,谢谢!这似乎奏效了,我用自己的电子邮件做的所有测试都奏效了。然而,我这个周末公开了,大多数正确提交表格的人(即,回复记录在谷歌表格中)都没有收到确认电子邮件(我也没有收到抄送)。然而,有一对夫妇做到了。我无法区分谁去了谁没去。有什么想法吗?嗯,又发生了。它每天发送的电子邮件数量有限制吗?每天100个收件人在这种情况下,会发送50个。哦,天哪,那不好。。。我想用这个来买票。有没有办法提高这个限额?或者在超过时收到警告?
    GmailApp.sendEmail(sender, subject, textbody, { 
                          cc: cc, 
                          name: sendername, 
                          htmlBody: message, 
                          from: "alias@example.com"
                      });