My Google Apps Script worked in testing, then initially, in test deployment but then started failing with the following error..
Error
GoogleJsonResponseException: API call to gmail.users.messages.delete failed with error: Requested entity was not found.
deleteForever @
(anonymous) @
This script was for my own personal use to delete certain labelled emails permanently from the trash.
function deleteForever(userId, labelName) {
var threads = GmailApp.search("in:trash label:" + labelName);
for (var i = 0; i < threads.length; i++) {
Gmail.Users.Messages.remove(userId, threads[i].getId());
}
}
deleteForever("me", "permadel")
FYI, I know very little about this scripting language or the the set up so please someone hold my hand if they know the answer.
It was weird that it worked when I pressed “run” in the editor. Then, I think I selected “Test Deployment” to add it as a “developer addon” or it just added automatically and had it run every minute and it was working during testing in my gmail.