Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/6.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
Email 谷歌表单邮件通知脚本。电子邮件中总是有;“我”;作为发送者_Email_Google Apps Script_Notifications_Google Forms - Fatal编程技术网

Email 谷歌表单邮件通知脚本。电子邮件中总是有;“我”;作为发送者

Email 谷歌表单邮件通知脚本。电子邮件中总是有;“我”;作为发送者,email,google-apps-script,notifications,google-forms,Email,Google Apps Script,Notifications,Google Forms,我曾尝试使用搜索功能,但没有找到解决问题的方法,或者我还不够了解 我为谷歌表单编写了一个脚本,当用户提交表单时,它会自动向两个电子邮件地址发送一封电子邮件。我内置了一些应该在电子邮件主题中显示的信息,并使用一些简单的HTML格式将表单输入到电子邮件中 我的问题是,电子邮件总是以我的电子邮件地址作为发件人(我用于创建表单的帐户) 我想有发件人的电子邮件,一个是提交表格。 这怎么可能 代码如下: function sendFormByEmail(e) { // Sent to

我曾尝试使用搜索功能,但没有找到解决问题的方法,或者我还不够了解

我为谷歌表单编写了一个脚本,当用户提交表单时,它会自动向两个电子邮件地址发送一封电子邮件。我内置了一些应该在电子邮件主题中显示的信息,并使用一些简单的HTML格式将表单输入到电子邮件中

我的问题是,电子邮件总是以我的电子邮件地址作为发件人(我用于创建表单的帐户) 我想有发件人的电子邮件,一个是提交表格。 这怎么可能

代码如下:

    function sendFormByEmail(e) 
{    
  // Sent to Email address
  var email1 = "123@abc.com";
  var email2 = "345@abc.com"; 


  // Variables

  var s = SpreadsheetApp.getActiveSheet();
  var headers = s.getRange(1,1,1,s.getLastColumn()).getValues()[0];
  var txt = "";
  var subject = "Example text: ";

  // Var e = form input as array.
  // Loop through the array.

  for(var i in headers){
    txt += "<b>" + headers[i] + '</b>' + ': '+ 
e.namedValues[headers[i]].toString() + '<br><br>';    
  }

  // Insert variables from the spreadsheet into the subject.
  // Create email subject
  subject += "Example text " + e.namedValues[headers[2]].toString();

  // Send the email
  MailApp.sendEmail(email1, subject, "", {htmlBody:txt});
  MailApp.sendEmail(email2, subject, "", {htmlBody:txt}); 

}
函数sendFormByEmail(e)
{    
//发送至电子邮件地址
var email1=”123@abc.com";
var email2=”345@abc.com"; 
//变数
var s=SpreadsheetApp.getActiveSheet();
var headers=s.getRange(1,1,1,s.getLastColumn()).getValues()[0];
var txt=“”;
var subject=“示例文本:”;
//Var e=作为数组的表单输入。
//在数组中循环。
for(标题中的变量i){
txt+=''+标题[i]+''+:'+
e、 namedvalue[headers[i]].toString()+'

'; } //将电子表格中的变量插入主题。 //创建电子邮件主题 subject+=“示例文本”+e.namedvalue[headers[2]].toString(); //发送电子邮件 sendmail(email1,主题,“,{htmlBody:txt}); sendmail(email2,主题,“,{htmlBody:txt}); }
无法以提交表单的用户的身份发送邮件,因为脚本正在从用户帐户运行,mailapp将仅从该帐户发送邮件。您可以根据提交表单的用户名通过参数name更改显示名称。您还可以将电子邮件更改为noreply@domainName.com通过在mailApp语法中添加参数noReply。但是,您不能将其更改为提交表单的用户

有关上述参数,请参阅本文档:

希望这能有所帮助