Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/349.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 谷歌api:如何将文件附加到电子邮件、表单驱动器?_Python_Google Api_Google Drive Api_Gmail - Fatal编程技术网

Python 谷歌api:如何将文件附加到电子邮件、表单驱动器?

Python 谷歌api:如何将文件附加到电子邮件、表单驱动器?,python,google-api,google-drive-api,gmail,Python,Google Api,Google Drive Api,Gmail,我只找到这个解决办法 但它并不有效——因为文件下载到本地,然后作为附件发送 bytes: Utilities.base64Encode(file.getBlob().getBytes()) 参见中提供的样本 Gmail的附件。这是一个常规的,除了它 有一个比调用 .长度,不计入Gmail读取 配额 要了解更多关于Gmail API Users.messages.attachments方法的信息,您可以参考。您的代码如何?您正在阅读收件箱中的消息,但我不需要阅读inpobx,我需要发送带有附件的

我只找到这个解决办法 但它并不有效——因为文件下载到本地,然后作为附件发送

bytes: Utilities.base64Encode(file.getBlob().getBytes())

参见中提供的样本

Gmail的附件。这是一个常规的,除了它 有一个比调用 .长度,不计入Gmail读取 配额


要了解更多关于Gmail API Users.messages.attachments方法的信息,您可以参考。

您的代码如何?您正在阅读收件箱中的消息,但我不需要阅读inpobx,我需要发送带有附件的电子邮件表单google sheets。没有下载工作表到我的本地服务器。只需通过id将谷歌表单附加到新电子邮件。
// Logs information about any attachments in the first 100 inbox threads.
var threads = GmailApp.getInboxThreads(0, 100);
var msgs = GmailApp.getMessagesForThreads(threads);
for (var i = 0 ; i < msgs.length; i++) {
  for (var j = 0; j < msgs[i].length; j++) {
    var attachments = msgs[i][j].getAttachments();
    for (var k = 0; k < attachments.length; k++) {
      Logger.log('Message "%s" contains the attachment "%s" (%s bytes)',
                 msgs[i][j].getSubject(), attachments[k].getName(), attachments[k].getSize());
    }
  }
}