Has anyone else found that the Advanced Gmail Service call
`Gmail.Users.Messages.remove(me, id)`
is now giving errors? Does anyone have a fix?
I had a reliable script that deleted Spam and Trash every few hours. Since about 21 Feb 17 it is giving the error "Not Found" even when passed a valid thread ID.
This is the script. I've added some logging messages
function deleteForever() {
var threads = GmailApp.getSpamThreads(0, 100);
var me = Session.getActiveUser().getEmail();
for (var i = threads.length -1; i >=0; i--) {
var thisid=threads[i].getId();
Logger.log("Removing thread " +i + ' of ' + threads.length + " from Spam with ID = " + thisid);
try {
var thisthread=GmailApp.getThreadById(thisid);
Logger.log("Found the thread.");
Gmail.Users.Messages.remove(me, thisid);
}catch(err) {
Logger.log("Error " + err.message);
};
}
Logger.log("Finished removing " + threads.length + " threads from Spam.");
var threads = GmailApp.getTrashThreads(0, 100);
for (var i = threads.length -1; i >=0; i--) {
Logger.log("Removing thread " +i + ' of ' + threads.length + " from Trash");
try {
Gmail.Users.Messages.remove(me, threads[i].getId());
} catch(err) {
Logger.log("Error " + err.message);
};
}
Logger.log("Finished removing " + threads.length + " threads from Trash.");
}
Now it is just giving a Not Found Error.
[17-02-25 11:45:49:790 GMT] Removing thread 17 of 18 from Spam with ID = 15a6fe6c1a86a020
[17-02-25 11:45:49:829 GMT] Found the thread.
[17-02-25 11:45:49:959 GMT] Error Not Found
[17-02-25 11:45:49:959 GMT] Removing thread 16 of 18 from Spam with ID = 15a6fe6c168f4a03
[17-02-25 11:45:50:000 GMT] Found the thread.
[17-02-25 11:45:50:129 GMT] Error Not Found
[17-02-25 11:45:50:130 GMT] Removing thread 15 of 18 from Spam with ID = 15a6fed29f6650b3
[17-02-25 11:45:50:165 GMT] Found the thread.
[17-02-25 11:45:50:294 GMT] Error Not Found
.....
`
Notice that thisid is definitely set to a valid ID before attempting the remove operation.