per a blog, I've tried running the following script to bulk delete, but it keeps timing out (after being debugged). any suggestions?
function deleteOldEmail() {
var batchSize = 100
while (true) {
var threads = GmailApp.search('is:unread emails: after:2016/12/31 before:2018/1/1');
for (j = 0; j < threads.length; j+=batchSize) {
GmailApp.moveThreadsToTrash(threads.slice(j, j+batchSize));
}
}
}