从电子表格发送电子邮件,包含整个格式和边框 [英] Send email from a spreadsheet with whole formatting and borders

查看:116
本文介绍了从电子表格发送电子邮件,包含整个格式和边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正尝试从谷歌电子表格发送邮件,但所有邮件都是[object Object],这里是我的脚本。

Hi am trying to send a table to a mail from a google spreadsheet but all am getting is "[object Object]" in mail, here is my script.

function sendEmail() {
  var s = SpreadsheetApp.getActive().getSheetByName('Summary');
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var range = ss.getActiveSheet().getDataRange();
  var range = s.getRange('A1:D8');
  var to = "srinath@example.com";
  var body = '';
  var htmlTable = SheetConverter.convertRange2html(range);
var body = "Here is the table:<br/><br/>"
     + htmlTable
     + "<br/><br/>The end."

  MailApp.sendEmail(to, 'Subject', {htmlBody: body});
};

我想发送整个表格并将其格式化为邮件正文
我有了Sheetconverter来自此链接的图书馆使用MailApp从htmlBody中的电子表格发送格式化的数据
请帮助我

I want t send the whole table and formatting in to tha mail body I got Sheetconverter Libraries from this link Use MailApp to send formatted data from spreadsheet in htmlBody Please help me

推荐答案

邮件的正文,您需要包含专门指出存在HTML正文的选项。

When sending HTML in the body of an email, you need to include options specifically stating that there is an HTML body.

MailApp.sendEmail(email, 'Subject', body, {htmlBody: body})

:body} 位是你缺少的地方。

修改后的代码:

Modified code:

function sendEmail() {
  var s = SpreadsheetApp.getActive().getSheetByName('Summary');
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var range = ss.getActiveSheet().getDataRange();
  var range = s.getRange('A1:D8');
  var to = "srinath@example.com";
  var body = '';
  var htmlTable = SheetConverter.convertRange2html(range);
var body = "Here is the table:<br/><br/>"
     + htmlTable
     + "<br/><br/>The end."

  MailApp.sendEmail(to, 'Subject', body, {htmlBody: body});
};

这篇关于从电子表格发送电子邮件,包含整个格式和边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆