javascript - Sub match in javascrtip/apps script get's "null" result -
javascript - Sub match in javascrtip/apps script get's "null" result -
hi have mails in gmail replied different answer-templates depending on keywords in subject.
in illustration have 5 emails that's beingness scanned, , if have word "prodcution" in subject should logg "sucess!", there 1 mail service contains word production, logger writes out "sucess!" 5 times, want write out 1 time mail service contains word "production". doing wrong?
function msmama() { var threads = gmailapp.getinboxthreads(0, 5); (var = 0; < threads.length; i++) { var message = threads[i].getmessages()[0]; var sub = message.getsubject(); var res = sub.match(/production/g); if (res = "production"){ logger.log("sucess!"); } }
replace
if (res = "production"){
with
if (res === "production"){
also match
returns array or null if there no results, improve approach be:
if (res)
javascript google-apps-script
Comments
Post a Comment