[英]How to send a Google Sheet as an email attachment?
我目前正在嘗試使用 Google Apps 腳本將 Google 表格作為 email 附件發送。 當我執行代碼(如下所示)時,它會自動將其作為 PDF 發送,即使我沒有指定我想以這種格式發送它。
有沒有辦法以 Google 表格格式發送附件?
function emailGoogleSheet()
{
try
{
// Get file from Google Drive
var googleSheet = DriveApp.getFileById("xxxxxxxxxxxxxxxx")
// Send email with file attached
MailApp.sendEmail("name@email.co.uk", "Report", "Please see the attached report.", {attachments: googleSheet})
}
catch (exception)
{
Logger.log(exception);
}
}
這是一個普通的 Blob
內容類型
要轉換為的 MIME 類型。 對於大多數 blob,“application/pdf”是唯一有效的選項。
以下代碼將完成工作
const file = DriveApp.getFileById("xxxxxxxxxxxxxxxx");
GmailApp.sendEmail(
'email',
'subject',
new_emailbody,
{
htmlBody: new_emailbody,
attachments: [file]
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.