Google API Test

function onOpen() {
getTVID();
}

function getTVID() {
var sheet = SpreadsheetApp.getActiveSheet();
sheet.getRange(‘A1:Z100’).clearContent();
var threads = GmailApp.search(‘from:tv@gmail.com “TV on “‘);
for (var i=0; i < threads.length; i++) { var messages = threads[i].getMessages(); for (var j=0; j < messages.length; j++) { if (!messages[j].isUnread()) { continue; } tid=messages[j].getSubject(); pid=messages[j].getSubject(); dte= messages[j].getDate(); tvid=tid.slice(tid.length-9, tid.length); pvid=pid.slice(5, tid.length-12); sheet.appendRow([dte,pvid,tvid]); } } }

Leave a Reply

Your email address will not be published. Required fields are marked *