Sending Email populated by google sheets -



Sending Email populated by google sheets -

our engineering science section has request form on google our company uses notify of projects , other issues need attending. requests assigned project lead in our weekly meeting. i'm trying write script populate email using info spreadsheet form driving notify both requester , project lead can contact each other straight instead of email in engineering science grouping updates. tried splicing 2 different codes accomplish unable find code adapt fit our goal. have listed links below codes used write have.

https://developers.google.com/apps-script/articles/sending_emails

https://www.youtube.com/watch?v=_tokh2jlqys

the code tells me "invalid email:" , highlights mailapp.sendemail, real email addresses. can help? haven't written code since high school web design. considering using form of notification in few of our other departments well. assuming version work.

function sendemails() { var sheet = spreadsheetapp.getactivesheet(); var startrow = 2; //first row of info process var numrows = 2; //number of rows process // fetch range of cells a2:l3 var datarange = sheet.getrange(startrow, 1, numrows, 12) // fetch values each row in range. var info = datarange.getvalues(); (var = 0; < data.length; ++i) { var row = data[i]; var requestername = row[1]; // sec column var emailaddr = row[2]; // 3rd column var requestspecifics = row[5]; // 6th column var projectlead = row[6]; // 7th column var projectleademail = ""; // 10th column else if (projectlead == "tom smith") {projectleademail = "tom@fakeemail.com";} else if (projectlead == "dick smith") {projectleademail = "dick@fakeemail.com";} else if (projectlead == "harry smith") {projectleademail = "harry@fakeemail.com";} else if (projectlead == "none") {projectleademail = null;} var emailsent = row[12]; // lastly column if (emailsent !=email_sent) { // prevents sending duplicates var myheader = "minor engineering science projects requests"; mailapp.sendemail({ to:emailaddr, subject:myheader body:requestername + ", \n\n + requestspecifics + " \n\nthe request submitted, listed above, has been assigned " + projectlead + ". \nplease contact person concerns. \n\nthank you, \n\nengineering", cc:projectlead]); sheet.getrange(startrow + i,12).setvalue(email_sent); // create sure cell updated right away in case script interrupted spreadsheetapp.flush(); } } }

i don't know if code above exact copy/paste of actual script if has lot of syntax errors (hopefully) corrected, please give try, should work if construction of spreadsheet right...

function sendemails() { var sheet = spreadsheetapp.getactivesheet(); var startrow = 2; //first row of info process var numrows = 2; //number of rows process // fetch range of cells a2:l3 var datarange = sheet.getrange(startrow, 1, numrows, 12) // fetch values each row in range. var info = datarange.getvalues(); (var = 0; < data.length; ++i) { var row = data[i]; var requestername = row[1]; // sec column var emailaddr = row[2]; // 3rd column var requestspecifics = row[5]; // 6th column var projectlead = row[6]; // 7th column var projectleademail = ""; // 10th column if (projectlead == "tom smith") {projectleademail = "tom@fakeemail.com";} else if (projectlead == "dick smith") {projectleademail = "dick@fakeemail.com";} else if (projectlead == "harry smith") {projectleademail = "harry@fakeemail.com";} else if (projectlead == "none") {projectleademail = null;} var emailsent = row[12]; // lastly column if (emailsent !="email_sent") { // prevents sending duplicates var myheader = "minor engineering science projects requests"; mailapp.sendemail({ to:emailaddr, subject:myheader, body:requestername + ", \n\n" + requestspecifics + " \n\nthe request you"+ "submitted, listed above, has been assigned " + projectlead + ". \nplease contact person concerns. \n\nthank you, \n\nengineering", cc:projectlead}); sheet.getrange(startrow + i,12).setvalue("email_sent"); // create sure cell updated right away in case script interrupted spreadsheetapp.flush(); } } }

email google-apps-script

Comments

Popular posts from this blog

java - Bypassing "final local variable defined in an enclosing type" -

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -