且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何删除GMail标签 - Google Apps脚本

更新时间:2023-12-05 18:59:34

如果您想删除 FollowUp,你可以使用 label.deleteLabel()。但是,由于您只是希望将标签从要恢复到收件箱的线程中取出,因此您需要循环访问它们。

If you wanted to remove "FollowUp" from all threads, you could use label.deleteLabel(). But since you're just interested in taking that label off of the threads you're restoring to the Inbox, you need to loop through them.

function moveToInbox(threadArray) {
  GmailApp.moveThreadsToInbox(threadArray);
  var label = GmailApp.getUserLabelByName("FollowUp");
  for (var i=0; i< threadArray.length; i++) {
    threadArray[i].removeLabel(label);
  }
}