2

我有一段代码应该为线程中的每封电子邮件创建一个文件夹,并将正文(作为 pdf 格式)和所有附件(无论它们是什么)保存到该文件夹​​中。

如果我在没有保存附件的循环的情况下运行它,我没有问题。(好吧,我对不同的线程有不同的问题)。如果我取消注释附件循环,我会得到

Service invoked too many times in a short time: driveWriteVolume rateMax. Try Utilities.sleep(1000) between calls. (line 156, file "Code")

创建文件夹或文件的所有行后面都跟有 aUtilities.sleep(sleepTime);并且 sleeptime 当前设置为 1000。更改它似乎没有任何效果。

有问题的代码是:

        // Save attachments
        for(var i = 0; i < messageAttachments.length; i++) {
          var attachmentBlob = messageAttachments[i].copyBlob();
          newFolder.createFile(attachmentBlob);
          Utilities.sleep(sleepTime);  // wait after creating something on the drive.
        } // each attachment

它是newFolder.createFile(attachmentBlob);触发错误的行。

我看过什么是 driveWriteVolume rateMax?Intermittant DriveWriteVolume rateMax异常求助,都没有找到。

请注意,如果我注释掉附件的循环,并将邮件正文保存为 PDF,那么无论我保存多少电子邮件,我都没有问题。当我收到错误时,脚本已经死在它应该保存第一个附件的地方。所以我认为除了超出某种限制之外还有其他问题。

4

1 回答 1

0

你达到了速率限制。Google api 可能有大约 20 次写入 / 分钟的限制,因此您需要放慢脚本速度以避免触发速率限制。在什么是 driveWriteVolume rateMax?类似线程中的用户使用 3000 毫秒的时间来解决问题,而不是建议的 1000 毫秒。

于 2013-05-26T12:59:37.557 回答