title: Extract the exact subjects and update the google sheets using apps script
body: <p>I have found a below mentioned apps script to get the subject name of the emails from the particular label and update the google sheets.</p>
  
  <pre><code>function getSubjects() {
  var sheet = SpreadsheetApp.getActiveSheet();
  var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
  
  var label = GmailApp.getUserLabelByName("Test");
  var threads = label.getThreads();
  var row = 2;
  
  for (var i = 0; i &lt; threads.length; i++) {
  var messages=threads[i].getMessages();
  
  for (var m=0; m &lt; messages.length; m++) {  
  sheet.getRange(row,1).setValue(messages[m].getSubject());
  row++;
    }
   }
  };
  </code></pre>
  
  <p>On daily basis, I will receive more than 100 emails with the same subject lines with small modifications. So, I need to get in the google sheets only the emails that have a subject line which includes the word "Pending".  </p>
  
  <p>I am hoping someone can help me make this example work.</p>