title: How to read all mails from inbox in google script?
body: <p>the script below returns only records of 500 mails. the google developer help states clearly "Where the thread size is unknown, and potentially very large, please use the 'paged' call, and specify ranges of the threads to retrieve in each call." 
  what is paged call ? how to do it ? 
  I have even tried <code>GmailApp.getInboxThreads(start,end)</code> it displays error if the parameters are >500.
  how to read all the 22000 mails in my inbox ?</p>
  
  <pre><code>//google script
  function spreadsheetSaver() 
  {
     var emailSheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0];
     emailSheet.clear();
      var thread = GmailApp.getInboxThreads();
      var row = 1;
      for(var i=0;i&lt;thread.length;i++)
      {
        var mail = thread[i].getMessages();
        for(var msg in mail)
        {
          var message = mail[msg];
          if (message &amp;&amp; message.isInInbox())
          {
            var txt = message.getPlainBody();
            emailSheet.getRange(row++,1).setValue(txt);
          }
        }
      }
  };
  </code></pre>
  
  <p>the expected output must save all the 22000 mails in a spreadsheet</p>