Delete all Labels

// function to delete all labels

function deleteAllLabels() {

var sheet = SpreadsheetApp.openById(SSID).getSheetByName('Labels'); sheet.clear();

var response =

Gmail.Users.Labels.list('me');

for (var i = 0; i < response.labels.length; i++) {

var label = response.labels[i];

if (label.type == 'user') {

Gmail.Users.Labels.remove('me', label.id); sheet.appendRow([i, "deleted", label.name, label.id]);

}

}

}