Google apps script 使用谷歌脚本通过电子邮件发送范围
我想通过电子邮件发送范围 例如: 我试过这个:Google apps script 使用谷歌脚本通过电子邮件发送范围,google-apps-script,range,sendmail,Google Apps Script,Range,Sendmail,我想通过电子邮件发送范围 例如: 我试过这个: function sendInvoiceList(){ var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Invoice").getRange("A1:B10").getValues(); var message = sheet; var email_subj = "Invoice " + Utilities.formatDate(new Date(),
function sendInvoiceList(){
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Invoice").getRange("A1:B10").getValues();
var message = sheet;
var email_subj = "Invoice " + Utilities.formatDate(new Date(), "GMT+1:00", "dd.MM.yyyy");
MailApp.sendEmail({
to: "user@gmail.com",
subject: email_subj,
htmlBody: "Please send us this list:<br><br><br>" + message
});
}
函数sendInvoiceList(){
var sheet=SpreadsheetApp.getActiveSpreadsheet().getSheetByName(“发票”).getRange(“A1:B10”).getValues();
var消息=工作表;
var email_sub=“Invoice”+Utilities.formatDate(新日期(),“GMT+1:00”,“dd.MM.yyyy”);
MailApp.sendmail({
至:user@gmail.com",
主题:电子邮件,
htmlBody:“请将此列表发送给我们:”+消息 }); } 系统将发送以下消息: textA1、textA2、textA3、textA4、textA5、textA6、textA7、textA8、textA9、textA10 我需要A1:B10范围内的值,但系统只需要A1,用逗号分隔,我需要列格式 怎么做? 谢谢你的支持
Angelo您需要重新考虑将消息设置为二维数组。我想这可能更接近你想要的。我用我自己的一些数据进行了测试,但不知道你有什么。如果需要更多帮助,请共享电子表格的图像
function sendInvoiceList(){
var ss=SpreadsheetApp.getActive()
var sh=ss.getSheetByName("Invoice");
var rg=sh.getRange("A1:B10")
var vA=rg.getValues();
var html='<style>td,th{border:1px solid black;}</style><table>';
vA.forEach(function(r,i){
html+='<tr>';
r.forEach(function(c,j){
if(i=0) {
html+=Utilities.formatString('<th>%s</th>',c)
}else{
html+=Utilities.formatString('<td>%s</td>',c)
}
});
html+='</tr>';
});
html+='</table>';
var email_subj = "Invoice " + Utilities.formatDate(new Date(), "GMT+1:00", "dd.MM.yyyy");
MailApp.sendEmail({to: "user@gmail.com",subject: email_subj,htmlBody: "Please send us this list:<br><br><br>" + html});
//SpreadsheetApp.getUi().showModelessDialog(HtmlService.createHtmlOutput(html), 'Display');//Just a dialog for testing the html
}
函数sendInvoiceList(){
var ss=SpreadsheetApp.getActive()
var sh=ss.getSheetByName(“发票”);
var rg=sh.getRange(“A1:B10”)
var vA=rg.getValues();
var html='td,th{border:1px纯黑色;}';
vA.forEach(函数(r,i){
html+='';
r、 forEach(函数(c,j){
如果(i=0){
html+=实用程序.formatString('%s',c)
}否则{
html+=实用程序.formatString('%s',c)
}
});
html+='';
});
html+='';
var email_sub=“Invoice”+Utilities.formatDate(新日期(),“GMT+1:00”,“dd.MM.yyyy”);
MailApp.sendEmail({收件人:user@gmail.com,主题:email_subj,htmlBody:“请将此列表发送给我们:”+html}); //SpreadsheetApp.getUi().showModelessDialog(HtmlService.createHtmlOutput(html),“Display”);//只是一个用于测试html的对话框 }
您需要重新考虑将消息设置为二维数组。我想这可能更接近你想要的。我用我自己的一些数据进行了测试,但不知道你有什么。如果需要更多帮助,请共享电子表格的图像
function sendInvoiceList(){
var ss=SpreadsheetApp.getActive()
var sh=ss.getSheetByName("Invoice");
var rg=sh.getRange("A1:B10")
var vA=rg.getValues();
var html='<style>td,th{border:1px solid black;}</style><table>';
vA.forEach(function(r,i){
html+='<tr>';
r.forEach(function(c,j){
if(i=0) {
html+=Utilities.formatString('<th>%s</th>',c)
}else{
html+=Utilities.formatString('<td>%s</td>',c)
}
});
html+='</tr>';
});
html+='</table>';
var email_subj = "Invoice " + Utilities.formatDate(new Date(), "GMT+1:00", "dd.MM.yyyy");
MailApp.sendEmail({to: "user@gmail.com",subject: email_subj,htmlBody: "Please send us this list:<br><br><br>" + html});
//SpreadsheetApp.getUi().showModelessDialog(HtmlService.createHtmlOutput(html), 'Display');//Just a dialog for testing the html
}
函数sendInvoiceList(){
var ss=SpreadsheetApp.getActive()
var sh=ss.getSheetByName(“发票”);
var rg=sh.getRange(“A1:B10”)
var vA=rg.getValues();
var html='td,th{border:1px纯黑色;}';
vA.forEach(函数(r,i){
html+='';
r、 forEach(函数(c,j){
如果(i=0){
html+=实用程序.formatString('%s',c)
}否则{
html+=实用程序.formatString('%s',c)
}
});
html+='';
});
html+='';
var email_sub=“Invoice”+Utilities.formatDate(新日期(),“GMT+1:00”,“dd.MM.yyyy”);
MailApp.sendEmail({收件人:user@gmail.com,主题:email_subj,htmlBody:“请将此列表发送给我们:”+html}); //SpreadsheetApp.getUi().showModelessDialog(HtmlService.createHtmlOutput(html),“Display”);//只是一个用于测试html的对话框 }
尝试将第三行替换为:
var message=''。加入(工作表)
尝试将第三行替换为:var message=''。加入(工作表)
你好,库珀,我尝试了你的代码,它工作正常!!我收到一个有两列的表。谢谢你的支持!AngeloHello Cooper,我试过你的代码,它工作正常!!我收到一个有两列的表。谢谢你的支持!安杰洛