Bas*_*asj 3 gmail google-apps-script gmail-api
GmailApp
在Google Apps脚本中使用时,我注意到以下限制:
var threads = GmailApp.search("to:test@example.com");
Logger.log(threads.length); // 250 max
var threads = GmailApp.search("label:mylabel");
Logger.log(threads.length); // 500 max
var label = GmailApp.getUserLabelByName('mylabel');
var threads2 = label.getThreads();
Logger.log(threads2.length); // 500 max
Run Code Online (Sandbox Code Playgroud)
您如何在500或250多个线程上进行工作(例如提取电子邮件地址并将其添加到列表中)?
您会通过按日期拆分来手动执行此操作吗(不是很漂亮,但可能还在工作)?
您可以使用max
例如100 的结果进行循环,并在结果的长度threads
小于时停止max
:
var max = 100;
var offset = 0;
var searchThreads = [];
while (true) {
var threads = GmailApp.search("to:test@example.com", offset, max);
searchThreads = searchThreads.concat(threads);
if (threads.length < max) {
break;
}
offset += max;
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1123 次 |
最近记录: |