【问题标题】:Gmail.Users.Messages.remove(me, id) - Not found errorGmail.Users.Messages.remove(me, id) - 未找到错误
【发布时间】:2017-02-25 11:56:06
【问题描述】:

有其他人发现高级 Gmail 服务调用

`Gmail.Users.Messages.remove(me, id)`

现在给出错误?有没有人有修复?

我有一个可靠的脚本,每隔几个小时就会删除一次垃圾邮件和垃圾邮件。自 17 年 2 月 21 日左右以来,即使传递了有效的线程 ID,它也会给出错误“未找到”。

这是脚本。我添加了一些日志消息

function deleteForever() {
  var threads = GmailApp.getSpamThreads(0, 100);
  var me = Session.getActiveUser().getEmail();
  for (var i = threads.length -1; i >=0; i--) {
     var thisid=threads[i].getId();
        Logger.log("Removing thread " +i + ' of ' + threads.length + " from Spam with ID = " + thisid);

    try {
    var thisthread=GmailApp.getThreadById(thisid);
    Logger.log("Found the thread.");
    Gmail.Users.Messages.remove(me, thisid);
    }catch(err) {
     Logger.log("Error " + err.message);
    };

  }
  Logger.log("Finished removing " + threads.length + " threads from Spam.");

  var threads = GmailApp.getTrashThreads(0, 100);
  for (var i = threads.length -1; i >=0; i--) {
        Logger.log("Removing thread " +i + ' of ' + threads.length + " from Trash");
    try {
    Gmail.Users.Messages.remove(me, threads[i].getId());
    } catch(err) {
    Logger.log("Error " + err.message);
    };
  }
  Logger.log("Finished removing " + threads.length + " threads from Trash.");
}

现在它只是给出一个 Not Found 错误。

[17-02-25 11:45:49:790 GMT] Removing thread 17 of 18 from Spam with ID = 15a6fe6c1a86a020
[17-02-25 11:45:49:829 GMT] Found the thread.
[17-02-25 11:45:49:959 GMT] Error Not Found
[17-02-25 11:45:49:959 GMT] Removing thread 16 of 18 from Spam with ID = 15a6fe6c168f4a03
[17-02-25 11:45:50:000 GMT] Found the thread.
[17-02-25 11:45:50:129 GMT] Error Not Found
[17-02-25 11:45:50:130 GMT] Removing thread 15 of 18 from Spam with ID = 15a6fed29f6650b3
[17-02-25 11:45:50:165 GMT] Found the thread.
[17-02-25 11:45:50:294 GMT] Error Not Found
.....
    `

请注意,在尝试删除操作之前,thisid 肯定设置为有效 ID。

【问题讨论】:

    标签: api google-apps-script gmail


    【解决方案1】:

    当搜索功能正在获取线程时,您正在删除消息。

    使用

    Gmail.Users.Threads.remove("me", threadId)
    

    而不是

    Gmail.Users.Messages.remove("me", threadId);
    

    【讨论】:

    • 是的,就是这样。大概在线程中只有 1 条消息的情况下,这是可行的,垃圾邮件或垃圾邮件包含线程的情况并不多,但其中的那些没有被删除。
    • 如果问题得到解决,请选择最佳答案并关闭此问题。
    猜你喜欢
    • 2019-11-11
    • 2021-08-02
    • 2019-06-09
    • 1970-01-01
    • 1970-01-01
    • 2020-12-08
    • 2020-02-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多