Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google apps script 如何从时间驱动触发器中清除Gmail垃圾_Google Apps Script_Gmail - Fatal编程技术网

Google apps script 如何从时间驱动触发器中清除Gmail垃圾

Google apps script 如何从时间驱动触发器中清除Gmail垃圾,google-apps-script,gmail,Google Apps Script,Gmail,我如何使用一个按特定时间间隔运行的脚本清除Gmail垃圾 // // A google app script for purgeing my gmail trash. // // It did work but is there a better way to do this ? // function delete_my_gmail_trash() { var threads = GmailApp.search( "in:trash" ); for ( var i =

我如何使用一个按特定时间间隔运行的脚本清除Gmail垃圾
//  
// A google app script for purgeing my gmail trash.
// 
// It did work but is there a better way to do this ?
//
function delete_my_gmail_trash() {
    var threads = GmailApp.search( "in:trash" );


    for ( var i = 0; i < threads.length; i++ ) {
        num_of_messages_in_the_thread = threads[i].getMessageCount();
        for ( var j = 0; j < num_of_messages_in_the_thread; j++ ) {
          Gmail.Users.Messages.batchDelete( {  "ids": [threads[i].getMessages()[j].getId() ]}, "me" );

        }
      }
}
//一个谷歌应用程序脚本,用于清除我的gmail垃圾。 // //它确实有效,但有更好的方法吗? // 函数delete\u my\u gmail\u trash(){ var threads=GmailApp.search(“in:trash”); 对于(var i=0;i您做了哪些研究?你检查过Gmail API或谷歌应用程序脚本的文档了吗?是的,这是可能的。请在问题中添加更多细节。正文中没有描述问题标题。DalmTo,thx以获取有用的答案->“是的,这是可能的”。这鼓励我深入阅读更多的文档。