【问题标题】:Delete all gmail promotions in gmail删除 gmail 中的所有 gmail 促销
【发布时间】:2019-09-08 12:17:56
【问题描述】:

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

"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());
  }
}

【问题讨论】:

  • 1.您激活了gmail api(高级谷歌服务)吗? 2. 用户名是否正确? 3. id应该是message id而不是thread id
  • 我在 Google App 脚本编辑页面的资源选项卡下点击了 Gmail,我在函数内部设置了一个变量,其中包含我的电子邮件帐户地址。

标签: google-apps-script gmail http-status-code-404 gmail-api


【解决方案1】:

问题:

  • 提供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☠️

参考资料:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多