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

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -