删除gmail中的所有gmail促销

Delete all gmail promotions in gmail

我正在尝试使用我找到并修改的以下代码删除我的促销标签中的所有电子邮件,但我收到错误

"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,而不是向接受 message id 的方法提供 message id。

解决方案:

  • 如果要按 ID 删除线程,请改用 Threads.remove

注意:

  • 使用Threads.remove立即并永久删除指定的线程。此操作无法撤消。更喜欢 Threads.trash 而不是

片段:

Gmail.Users.Threads.remove("me", threads[i].getId()); //☠️Permanently and irrevocably deletes the thread☠️

参考文献: