Google Apps Script - Gmail, delete forever e-mails in trash with specific label

前端 未结 5 981
囚心锁ツ
囚心锁ツ 2020-12-09 11:19

I\'m trying to make a script that automatically deletes e-mails from a certain sender immediately and permanently, as Gmail only allows for a filter which sends an e-mail to

5条回答
  •  借酒劲吻你
    2020-12-09 11:50

    try this

    function delete_all_mail(){
    var myspreadsheet = SpreadsheetApp.openById('1AG1fZ9BuS8***********');
    var mysheet = myspreadsheet.getSheets()[0];
    //0~500
    var threads = GmailApp.getInboxThreads(0 , 500);
      for(var i = 0; i < threads.length; i++)
      {
       threads[i].moveToTrash();
      }
    }
    

提交回复
热议问题