我正在尝试使用我找到并修改的以下代码删除“促销”标签中的所有电子邮件,但出现错误
"Response Code: 404. Message: Not Found. (line 4, file "Code")Dismiss"
这是我正在使用的代码:
function deleteForever(userId) {
var threads = GmailApp.search("category:social");
for (var i = 0; i < threads.length; i++) {
Gmail.Users.Messages.remove(userId, threads[i].getId());
}
}
答案 0 :(得分:1)
thread
id来删除,而不是向接受message
id的方法提供message
id。Threads.remove
。Threads.remove
并永久删除指定的线程。此操作无法撤消。改用Threads.trash
Gmail.Users.Threads.remove("me", threads[i].getId()); //☠️Permanently and irrevocably deletes the thread☠️