function getThreadsByLabel(label) { const threads = GmailApp.getUserLabelByName(label).getThreads(); var threadList = []; for (i = 0; i < threads.length; i++) { threadList.push(threads[i].getId()); } delete threads; return threadList; }