【发布时间】:2013-05-24 23:30:49
【问题描述】:
我有一段代码应该为线程中的每封电子邮件创建一个文件夹,并将正文(作为 pdf 格式)和所有附件(无论它们是什么)保存到该文件夹中。
如果我在没有保存附件的循环的情况下运行它,我没有问题。 (好吧,我对不同的线程有不同的问题)。如果我取消注释附件循环,我会得到
Service invoked too many times in a short time: driveWriteVolume rateMax. Try Utilities.sleep(1000) between calls. (line 156, file "Code")
所有创建文件夹或文件的行后跟一个Utilities.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); 行。
我查看了What is driveWriteVolume rateMax? 和Intermittant DriveWriteVolume rateMax exception 寻求帮助,但没有找到。
请注意,如果我注释掉附件循环,并将邮件正文保存为 PDF,无论我保存多少电子邮件,我都没有问题。当我收到错误时,脚本已经死在它应该保存第一个附件的地方。所以我认为除了超出某种限制之外还有其他问题。
【问题讨论】:
标签: google-apps-script gmail google-sheets google-apps