使getThreads()应用脚本调用数超过500 [英] Make getThreads() app script call count over 500

查看:110
本文介绍了使getThreads()应用脚本调用数超过500的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用Suyash Gandhi的代码来计算每天属于特定标签的电子邮件数量.下面是我一直在使用的代码:

I have been using code from Suyash Gandhi in order to count the number of emails that fall under a certain label everyday. Below is the code I've been using:

function CountVoicemail() 
{
var label = GmailApp.getUserLabelByName("X140");
var labelname = label.getName();
var mails = label.getThreads();
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Data 
Sheet");
var date = new Date();
sheet.appendRow([labelname, date, mails.length]);
}

我有从Google表格运行的代码,该代码每天在我选择的指定时间运行,脚本将运行,并添加包含三列的新行;标签名称,脚本运行日期和时间,以及带有该特定标签的电子邮件总数.然后,我在实际的Google表格中有一个数组公式(在D列中)减去前一天的总数,以便计算当天收到的带有该标签的电子邮件数量(我在Gmail中设置了一个过滤器,用于从具体来源).直到最近,标签中的电子邮件数量超过500后,脚本中的getThreads()调用仍只会返回值500.直到现在,我可以使getThreads()调用返回值吗?大于500?如果没有,我可以使用另一个电话吗?我尝试为getThreads调用[getThreads(start,max)]指定范围,但这并不能真正帮到我,因为我想对标签中的电子邮件总数进行计数,以便从中计算当天的总数我的ArrayFormula.

I have the code running from a Google Sheet where everyday at a specified time I chose, the script will run and a new row with three columns will be added; the Label Name, the Date and Time the Script Ran, and the total number of emails with that specific label. I then have an Array Formula (in column D) in the actual Google Sheet subtract the previous day's total in order to calculate the number of emails received with that label for the day (I have a filter in Gmail set up to label emails from a specific source). This set up worked perfectly up until recently where once the number of emails in my label surpassed 500 the getThreads() call in the script would still only return the value of 500. Is there way that I make the getThreads() call return a value bigger than 500? If not is there another call I can use? I've tried specifying ranges for the getThreads call [getThreads(start, max)] but this doesn't really help me since I want to get a count of the total number of emails in my label in order to calculate the day's total from my ArrayFormula.

推荐答案

阅读以下内容: https://developers.google.com/apps-script/reference/gmail/gmail-label#getthreads

并查看 :

getThreads(start, max)
Gets a range of threads marked with this label.

// log the subject lines of up to the first 30 threads with the label MyLabel
var label = GmailApp.getUserLabelByName("MyLabel");
var threads = label.getThreads(0, 30);
for (var i = 0; i < threads.length; i++) {
  Logger.log(threads[i].getFirstMessageSubject());
}

这篇关于使getThreads()应用脚本调用数超过500的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆