Get Gmail categories

Gmail categories can easily be searched.

Here is a small code that looks for every promotion mail. The result is an array of threads, you can add Label to each of them so that your old script will be happy again ;-)

  var threads = GmailApp.search('category:promotions');// check the category Gmail added to the thread

documentation here


Here is a script I use to delete old promotional emails as well as some other categories and custom labels.

function auto_delete_email(){
  delete_Label ("Cameras",30);
  delete_Label ("Travel",365);
  delete_Category ("Social",90);
  delete_Category ("Finance",365*3);
  delete_Category ("Forums",90);
  delete_Category ("Promos",365*3);
}

function delete_Label(mailLabel,delayDays) {  
  var label = GmailApp.getUserLabelByName(mailLabel);   
  if (!label) {return false;}
  var maxDate = new Date(); 
  maxDate.setDate(maxDate.getDate()-delayDays);    
  var threads = label.getThreads();  
  for (var i = 0; i < threads.length; i++) {  
    if (threads[i].getLastMessageDate()<maxDate){  
      threads[i].moveToTrash();
    } 
  } 

function delete_Category(mailCategory,delayDays) {  
  var maxDate = new Date(); 
  maxDate.setDate(maxDate.getDate()-delayDays);    
  var threads = GmailApp.search('category:' + mailCategory);
  for (var i = 0; i < threads.length; i++) {  
    if (threads[i].getLastMessageDate()<maxDate){  
      threads[i].moveToTrash();
    } 
  } 
}