我正在尝试使用下面的脚本将Google表格文档中的第一张表格发送为PDF格式的电子邮件 . 要发送到的电子邮件列在单元格A1中 .
但是,此脚本将整个电子表格作为PDF发送,而不仅仅是第一个表单 . 我一直在尝试使用stackoverflow中的一些其他脚本,但这是唯一一个实际发送电子邮件的脚本 .
希望你们能帮助我 .
/* Email Google Spreadsheet as PDF */
function emailGoogleSpreadsheetAsPDF() {
// Send the PDF of the spreadsheet to this email address
var email = "amit@labnol.org";
// Get the currently active spreadsheet URL (link)
var ss = SpreadsheetApp.getActiveSpreadsheet();
// Subject of email message
var subject = "PDF generated from spreadsheet " + ss.getName();
// Email Body can be HTML too
var body = "Install the <a href='http://www.labnol.org/email-sheet'>Email Spreadsheet add-on</a> for one-click conversion.";
var blob = DriveApp.getFileById(ss.getId()).getAs("application/pdf");
blob.setName(ss.getName() + ".pdf");
// If allowed to send emails, send the email with the PDF attachment
if (MailApp.getRemainingDailyQuota() > 0)
GmailApp.sendEmail(email, subject, body, {
htmlBody: body,
attachments:[blob]
});
}
1 回答
下面是一个工作版本,其中包含一些您可能想要使用的有用参数 .
更新代码