2017-02-25 29 views
0

有其他人发现,先进的Gmail服务呼叫Gmail.Users.Messages.remove(我ID) - 未发现错误

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

现在它只是给出一个未找到错误。

[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。

回答

3

您正在删除消息,而搜索功能正在提取线程。

使用

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

代替

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

是,就是这样。据推测,在线程中只有1条消息的情况下,这种方法奏效了,垃圾邮件或垃圾包含一个线程的情况并不是很多,但那些线程没有被删除。 –

+0

如果问题得到解决,请选择最佳答案并关闭此问题。 –