【问题标题】:Gmail API with Attachments带附件的 Gmail API
【发布时间】:2015-06-11 12:07:18
【问题描述】:

如何使用 Gmail API 从 Apps 脚本发送电子邮件,该 API 从云端硬盘中提取文件并作为附件包含在邮件中。

我查看了official documentation,但无法使其正常工作。

【问题讨论】:

    标签: google-apps-script gmail-api


    【解决方案1】:

    您可以在不使用 GMail API 的情况下完成此操作,而是使用 GmailApp 服务。实际上,您的用例就是GmailApp.sendEmail() 的文档中提供的示例。

     // Send an email with a file from Google Drive attached as a PDF.
     var file = DriveApp.getFileById('1234567890abcdefghijklmnopqrstuvwxyz');
     GmailApp.sendEmail('mike@example.com', 'Attachment example', 'Please see the attached file.', {
         attachments: [file.getAs(MimeType.PDF)],
         name: 'Automatic Emailer Script'
     });
    

    【讨论】:

      猜你喜欢
      • 2020-10-12
      • 1970-01-01
      • 2016-12-21
      • 2016-05-29
      • 2020-05-16
      • 2018-11-11
      • 2016-09-22
      • 1970-01-01
      • 2014-11-08
      相关资源
      最近更新 更多