Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29745

Google Sheet Email script to email multiple cells of row that was edited in a different cell

$
0
0

I am really struggling with some code I am putting together to email certain cells when a edit takes place on a the same row. The issue I have is I have multiple sheets on the same spreadsheet, and currently it is emailing me when I edit a different sheet. I know i will be doing something stupid but I can not work it out.

I have attached the script, any help would be greatly appreciated.

function onSheetEdit(e) {  var source = SpreadsheetApp.getActiveSpreadsheet();//Specifies the current spreadsheet  var source_sheet = source.getSheetByName('SHOP Sites In Progress');//Specifies the sheet to monitor for changes  var range = source_sheet.getDataRange();//Gets the data range for the entire sheet  var ActiveRow = source_sheet.getActiveRange().getRow();//Identifies the row that the change occurred in  var columns = "21";//Specifies how many columns of data your sheet has  var data = source_sheet.getRange(ActiveRow,1,1,21).getValues();//(StartRow,StartColumn,NumberofRowstoGet,NumberofColumnstoGet)  var emailAddressToNotify = 'test@email.com'  var columnA = data[0][0];  var columnB = data[0][1];  var columnC = data[0][2];  var columnD = data[0][3];  var columnE = data[0][4];  var columnF = data[0][5];  var columnG = data[0][6];  var columnH = data[0][7];  var columnI = data[0][8];  var columnJ = data[0][9];  var columnK = data[0][10];  var columnL = data[0][11];  var columnM = data[0][12];  var columnN = data[0][13];  var columnO = data[0][14];  var columnP = data[0][15];  var columnQ = data[0][16];  var columnR = data[0][17];  var columnS = data[0][18];  var columnT = data[0][19];  var columnU = data[0][20];  var ss = SpreadsheetApp.getActiveSpreadsheet();  var emailSubject = 'Shop site in progress '+'Customer Name: '+ columnB +''+ columnC +''+'info updated'  var sheet = SpreadsheetApp.getActiveSheet();  // var emailBody = 'Person1 has approved the item on row '+ range.getRow() +' of spreadsheet "'+ ss.getName() +'".\n\n';  var emailBody = Session.getActiveUser().getEmail() +' Has approved the item on row '+ActiveRow+' of spreadsheet "'+ sheet.getName() +'".\n\n';  emailBody  += ''  emailBody  += 'Customer PINCODE : '+ columnA +'\n' ;  emailBody  += 'Customer Name: '+ columnB +''+ columnC +'\n';  emailBody  += 'Business Name: '+ columnD +'\n\n';    emailBody += 'To open the spreadsheet, click this link: '+ ss.getUrl() +'\n\n';  emailBody += '(this is an automatically sent message)';    MailApp.sendEmail(emailAddressToNotify, emailSubject, emailBody);}

Viewing all articles
Browse latest Browse all 29745

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>