Reputation: 1
Please take a look at the following googleapps script code. the spreadsheet it references has 4 values in it. in a2 is the value "Two". I want that when I run this code, i receive an email with "2" in the subject line. I seem to keep on receiving a "4". Any ideas?
function rowofspecificvalue(){
var sheet = SpreadsheetApp.openById("1rMUrZFie94RLFDKaWVBPsQ-jebL8wNA6qsZWivMBDTk").getActiveSheet();
var data = sheet.getRange("a1:a4").getValues();
for(var i = 0; i<data.length;i++){
if(data[i][1] == "Two"){
Logger.log((i+1))
return i+1;
}
} MailApp.sendEmail ("[email protected]", i, "");
}
Thanks!
Upvotes: 0
Views: 27
Reputation: 11
Write
MailApp.sendEmail("[email protected]", i-2, "")
and you will "2" have in subject. Second argument of MailApp.sendEmail() function set up subject of email.
Upvotes: 1