var EMAIL_LABEL = '__renew';
var query = 'in:inbox label:' + EMAIL_LABEL;
var threads = GmailApp.search(query);
var messages = GmailApp.getMessagesForThreads(threads);
for (var i = 0; i < messages.length; i++) {
for (var j = 0; j < messages[i].length; j++) {
Logger.log(messages[i][j].getDate() + ' ' + messages[i][j].getSubject());
}
}
.forSpreadsheet(ss)
.forSpreadsheet(sheet)
function check(sheetName, column, word) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName(sheetName);
var range = sheet.getRange(column);
var values = range.getValues();
var result = false;
for (var i = 0; i < values.length; i++) {
if (values[i][0] == word) {
result = true;
break;
}
}
return result;
}
var result = check('test', 'A:A', 'ask / organic');