我正在学习 Google-App-Script。我编写了一个非常简单的脚本来管理我的电子邮件:
var threads = GmailApp.search('label:Project1 is:unread');
GmailApp.markThreadsRead(threads);
这个脚本几乎可以完美运行。但是,当标签“Porject1”中有超过 100 封未读电子邮件时,我收到的错误消息最多为 100 封。允许更改 100 个线程。
如何将我的搜索命令限制为 99 次点击?或者是否有另一种方法可以一步管理所有点击?
最佳答案
您可以使用splice method :
function mailReader(){
var bigThreads = GmailApp.search('label:Project1 is:unread');
// While bigthreads bigger than 100 threads
while(bigThreads.length>99) {
// Split the bigThreads array in two
var littlethreads = bigThreads.splice(0,99);
// Mark those threads as unread
GmailApp.markThreadsRead(littlethreads);
}
// Mark the rest of the threads on bigThreads
GmailApp.markThreadsRead(bigThreads);
}
关于google-apps-script - 一步管理100多个点击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45630756/