title: Script to permenantly delete my emails with Google Script
body: <p>How does this Gmail.Users.Messages.remove(userId, id) work? What is the ID of the email and is it the right function to permanently delete an email?</p>
  <p>In my case I want to delete all my sent emails instantly and definitely. Here's some code I took from someone, only with a different label:</p>
  <pre><code>function myFunction() {
    var threads = GmailApp.search(&quot;in:sent label:Inbox&quot;);
    var me = Session.getActiveUser().getEmail();
      for (var i = 0; i &lt; threads.length; i++) {
        Gmail.Users.Messages.remove(me, threads[i]);
      }
  
  }
  </code></pre>
  <p>Is this in anyway correct and could anyone help me please?</p>
  <p>Edit: I modified my code but it's still not working ,I still can't figure out how to use the function remove,  here's it:</p>
  <pre><code>function myFunction() {
    
    var me = Session.getActiveUser().getEmail();
    var thread = Gmail.Users.Threads.list(me);
    for (var i = 0; i &lt; 1000; i++) {
          Gmail.Users.Threads.remove(me, thread);
          thread = Gmail.Users.Threads.list(me).nextPageToken;
       
    }
  
  }
  </code></pre>
  <p>Once the code is working , I'll put a trigger to run the function every minute. So that my Sent folder is always empty.</p>