我正在尝试使用以下代码删除促销选项卡中的所有电子邮件,但我收到错误
"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());
}
}
问题:
- 提供要删除
thread
id,而不是向接受 id 的方法提供message
idmessage
。
溶液:
- 如果要按 id 删除线程,请改用
Threads.remove
。
谨慎:
-
立即使用
Threads.remove
并永久删除指定的线程。此操作无法撤消。更喜欢Threads.trash
片段:
Gmail.Users.Threads.remove("me", threads[i].getId()); //☠️Permanently and irrevocably deletes the thread☠️
引用:
- 线程