patrick
patrick

Reputation: 826

Gmail: move from trash to archive using script

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

Answers (1)

Corey G
Corey G

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

Related Questions