title: Count number of Gmail emails per sender
body: <p>I'm trying to do a mass cleanout of my Gmail because search has gotten so slow.  I would like to tally how many emails i've received from each sender.  The closest solution I've found is this: <a href="https://webapps.stackexchange.com/questions/102162/can-i-get-a-list-of-the-senders-of-all-of-the-messages-in-my-inbox">https://webapps.stackexchange.com/questions/102162/can-i-get-a-list-of-the-senders-of-all-of-the-messages-in-my-inbox</a> however that only tallies emails in Inbox, not in All Mail.  I even tried moving all my 100k emails from All Mail to Inbox so that I could use it, but Gmail doesn't appear to let you move more than 3,500 messages in.</p>
  
  <p>How do I adjust the Google Apps script to analyze All Mail instead of just Inbox? Or any other way of doing this welcomed too</p>
  
  <pre><code>function sender_list() {
    var inbox_threads = GmailApp.getInboxThreads();
  
    var sender_array = [];
  
    for (var i = 0; i &lt; inbox_threads.length; i++) {
      var message = inbox_threads[i].getMessages();
      for (var x = 0; x &lt; message.length; x++) {
        var sender = message[x].getFrom();
        sender_array.push([sender]);      
      }
    }
    var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
    var sheet = spreadsheet.getSheetByName('sheet1');
    sheet.clear();
    sheet.appendRow(['Email Address']);
    sender_array.sort();
    sheet.getRange(sheet.getLastRow()+1, 1, sender_array.length,1).setValues(sender_array);
  }
  </code></pre>