I have this code, and I'm not getting why the getThreads
property is not being read.
Is getThreads()
deprecated or so?
function cleanUp() {
var delayDays = 2 // Enter # of days before messages are moved to trash
var maxDate = new Date();
maxDate.setDate(maxDate.getDate()-delayDays);
var label = GmailApp.getUserLabelByName("2dehands");
var threads = label.getThreads() || [];
for (var i = 0; i < threads.length; i++) {
if (threads[i].getLastMessageDate()<maxDate)
{
threads[i].moveToTrash();
}
}
}
TypeError: Cannot read property 'getThreads' of null
cleanUp @ Code.gs:6