【问题标题】:Google App Script Attaching an image from an OverGridImage to a MailApp emailGoogle App 脚本将图像从 OverGridImage 附加到 MailApp 电子邮件
【发布时间】:2020-01-24 22:12:16
【问题描述】:

我正在尝试使用 Google 表格创建表单。用户可以将数据输入到单元格中,完成一些事情,然后发送一封电子邮件。我想包括通过将图像片段粘贴到工作表中的单元格上来向该电子邮件添加图像片段的功能。我可以使用

收集 OverGridImage 数组
var images = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Input').getImages();

我已经使用

对电子邮件进行了排序
  MailApp.sendEmail({
    to: email,
    cc: cc,
    subject: subject,
    htmlBody: body,
    attachments:attachments

  });
}

但我非常坚持将 OverGridImage 数组更改为可以作为附件传递给 MailApp 的东西。

【问题讨论】:

  • 我可以问你关于I'm very stuck on changing the OverGridImage array into something that I can pass as an attachment to MailApp. 的事吗?你想把 OverGridImage 转换成什么 mimeType?而当有多个图片时,你希望OverGridImages如何转换为附件文件?

标签: google-apps-script google-sheets gmail email-attachments


【解决方案1】:

不幸的是,您想要的无法完成。 Google 表格无法返回图像的 blob,只能返回对图像的引用,这意味着您无法检索图像并在之后使用 Google Apps 脚本将它们附加到电子邮件中。

另一种方法是使用=IMAGE() 函数将图像插入单元格,然后您可以使用Sheets API V4 检索它们。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-06
    • 2016-12-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多