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]);
}
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.