我删除电子邮件的脚本似乎正在运行,但它什么也没做

My script to delete emails seems to be running but it does nothing

本文关键字:什么 运行 电子邮件 删除 脚本      更新时间:2023-09-26

我做了一个脚本来删除标有"发送邮件脚本"的电子邮件。它运行没有错误,但不会删除标有"发送邮件脚本"的电子邮件

下面是脚本:

function DeleteEmail() {
  var threads = GmailApp.search('label:Send Email Script');
  for (var i = 0; i < threads.length; i++) {
    var thread = threads[i],
        messages = thread.getMessages();

    thread.moveToTrash(messages);
  }
}

您需要将标签名称中的空格替换为短划线。请参阅更新的代码:

function DeleteEmail() {
  var threads = GmailApp.search('label:Send-Email-Script');    
  for (var i = 0; i < threads.length; i++) {
     threads[i].moveToTrash();
  }
}