Reputation: 826
I'm trying to move Threads form the Trash to the Archive of GMail by GMAIL Service in Google Apps Script. If I do this nothing happens:
var threads = GmailApp.getTrashThreads(0, 100);
for (var i = 0; i < threads.length; i++) {
threads[i].moveToArchive();
}
Do I make something wrong or is this a bug?
Upvotes: 0
Views: 1248
Reputation: 7858
Move to archive doesn't seem to work from trash. Please file an issue tracker report. However, as a workaround, this will do:
threads[i].moveToInbox().moveToArchive();
Although to be honest that code will be really slow and might time out. This will be much faster:
var threads = GmailApp.getTrashThreads(0, 100);
GmailApp.moveThreadsToInbox(threads);
GmailApp.moveThreadsToArchive(threads);
Upvotes: 1