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 如何从正文中包含的电子表格中使用谷歌应用程序脚本生成Gmail草稿_Google Apps Script_Google Sheets_Google Cloud Platform_Automation_Gmail - Fatal编程技术网

Google apps script 如何从正文中包含的电子表格中使用谷歌应用程序脚本生成Gmail草稿

Google apps script 如何从正文中包含的电子表格中使用谷歌应用程序脚本生成Gmail草稿,google-apps-script,google-sheets,google-cloud-platform,automation,gmail,Google Apps Script,Google Sheets,Google Cloud Platform,Automation,Gmail,我想从正文中的电子表格contains表中使用Google应用程序脚本生成Gmail草稿 下面是我的输入值和我想要的输出类型的屏幕截图 如果你能分享完整的GS代码,我将不胜感激,因为我是谷歌应用程序脚本的新手 此外,我还想在邮件正文中签名,“感谢和问候”是我正文的一部分 另外请注意,列E是动态的,意味着它可能有1行,并且可能超过1行 目前我正在使用这个代码 函数Email\u Loop\u BL(){ const signature=Gmail.Users.Settings.SendAs.li

我想从正文中的电子表格contains表中使用Google应用程序脚本生成Gmail草稿

下面是我的输入值和我想要的输出类型的屏幕截图

如果你能分享完整的GS代码,我将不胜感激,因为我是谷歌应用程序脚本的新手

此外,我还想在邮件正文中签名,“感谢和问候”是我正文的一部分


另外请注意,列E是动态的,意味着它可能有1行,并且可能超过1行

目前我正在使用这个代码

函数Email\u Loop\u BL(){
const signature=Gmail.Users.Settings.SendAs.list(“me”).SendAs.filter(函数(account){if(account.isDefault){return true}})[0]。签名;
var ss=SpreadsheetApp.getActiveSpreadsheet();
var sheet=ss.getActiveSheet();
var指数=2;
var index1=2;
var lastRow=sheet.getLastRow();
var data=sheet.getRange(1,5,10).getValues();
Logger.log(数据)
对于(;index1
函数sendmail(){
const ss=SpreadsheetApp.getActive();
const sh=ss.getSheetByName('Sheet1');
const rg=sh.getDataRange();
const vs=rg.getDisplayValues();
GmailApp.createDraft(vs[1][0].toString().split(/\n/).join(“,”),vs[1][2],“,{htmlBody:vs[1][3].toString().split(/\n/).join(“
”)+”+vs[1][4].toString().split(/\n/); }
我在表1中的数据:

草案:


您可以将更多电子邮件添加到收件人和抄送中,方法是将它们放在单元格中的不同行上,但用“
ctrl-enter”
终止每一行。发票也是如此。

谢谢,此外,我忘了提到我还想在GMAIL草稿中添加签名。“谢谢并致意”是我签名的一部分。另外请注意,列E是动态的,意味着它可能有一行或多行。我在我的示例中更改了这一点,因为如果您将它们放在同一个单元格中,用ctrl-enter分隔,代码会更容易,但是如果您希望按您的方式更改,我可以随意更改任何代码在我的情况下,你可以把你想放多少就放多少。这对收件人和收件人来说也是一样的,但是你能在我的代码中修改inseart表吗?因为我必须在多张纸上使用这个代码。
function sendemail() {
  const ss=SpreadsheetApp.getActive();
  const sh=ss.getSheetByName('Sheet1');
  const rg=sh.getDataRange();
  const vs=rg.getDisplayValues();
  GmailApp.createDraft(vs[1][0].toString().split(/\n/).join(','),vs[1][2],'',{htmlBody:vs[1][3].toString().split(/\n/).join('<br>') + '<br>' + vs[1][4].toString().split(/\n/).join('<br>') + '<br>' + vs[1][5],cc:vs[1][1].toString().split(/\n/).join(',')});
}