0

我不是程序员,但已将其他脚本复制并粘贴在一起,以便在提交时通过电子邮件发送某些表单。

如果谷歌表单上的一个答案是真的,我想获取一些提交的结果并填写我创建的另一个谷歌表单。这可能吗?谢谢。

这是我拼凑在一起的代码示例,用于在提交时通过电子邮件发送我们表单​​的结果。

    function sendFormByEmail(e) {
  var email = "xyxy@yyy.com";
    var subject = "Practice Referral Form";
  var msgHtml = e.values[5] + "," + "<br/> <br/> <br/>"
        + "Your instructor has referred you to practice the content/skills below. =" + "<br/>"
        + "<h1><b>Referral Information:</b></h1>"
        + "<b>Instructor:  </b> " + e.values[1] + "<br/>"
        + "<b>Instructor Email:  </b> " + e.values[2] + "<br/>"  
        + "<b>Date:  </b> " + e.values[0] + "<br/>"        
        + "<b>Required Content/Skills:  </b> " + e.values[3] + "<br/>"
        + "<b>Skills must be completed by:  </b> " + e.values[4] + "<br/>"
        + "<br/> <br/> "
        + "<b>Student Name: </b>" + e.values[5] + "<br/>"
        + "<br/> "



    var bccList = e.values[6];
  var optAdvancedArgs = {bcc: bccList, noReply: true, htmlBody: msgHtml};
    var msgPlain = msgHtml.replace(/\<br\/\>/gi, '\n').replace(/(<([^>]+)>)/ig, ""); // clear html tags and convert br to new lines for plain mail
  MailApp.sendEmail(email, subject, msgPlain, optAdvancedArgs);

}

4

1 回答 1

0

代码看起来很简单。您需要的更改也很简单。尝试这样的事情......

    function sendFormByEmail(e) {
      var email = "xyxy@yyy.com";
        var subject = "Practice Referral Form";
      var msgHtml = e.values[5] + "," + "<br/> <br/> <br/>"
            + "Your instructor has referred you to practice the content/skills below. =" + "<br/>"
            + "<h1><b>Referral Information:</b></h1>"
            + "<b>Instructor:  </b> " + e.values[1] + "<br/>"
            + "<b>Instructor Email:  </b> " + e.values[2] + "<br/>"  
            + "<b>Date:  </b> " + e.values[0] + "<br/>"        
            + "<b>Required Content/Skills:  </b> " + e.values[3] + "<br/>"
            + "<b>Skills must be completed by:  </b> " + e.values[4] + "<br/>"
            + "<br/> <br/> "
            + "<b>Student Name: </b>" + e.values[5] + "<br/>"
            + "<br/> "



        var bccList = e.values[6];
      var optAdvancedArgs = {bcc: bccList, noReply: true, htmlBody: msgHtml};
        var msgPlain = msgHtml.replace(/\<br\/\>/gi, '\n').replace(/(<([^>]+)>)/ig, ""); // clear html tags and convert br to new lines for plain mail
      MailApp.sendEmail(email, subject, msgPlain, optAdvancedArgs);

/* Write to the second spreadsheet */ 
var NEWSSID = 'ID_OF_THE_SECOND_FORM_SPREADSHEET'; 
// Assuming  e.values[3] is what you're checking
if (e.values[3].toLowerCase() == 'true'){
  var values = ['','','','',''] ; // Fill up with values you want to fill up in the new spreadsheet
  var ss = SpreadsheetApp.openById(NEWSSID);
  var sheet = ss.getSheetByName('SheetName'); //Replace name of the sheet here
  var row = sheet.getLastRow() + 1; 
  sheet.getRange(row, 1, 1, values.length).setValues([values]);
}

    }
于 2013-10-09T06:58:47.320 回答