I am trying to get forms to email certain cells to a specified email. I have gotten it to email the cells, but it won't email the new rows it just keeps emailing the first row to the email can someone help me with the code so it will email the newly added row and columns I need
function sendEmails() {
var sheet = SpreadsheetApp.getActiveSheet();
var startRow = 2; // First row of data to process
var numRows = 100; // Number of rows to process
// Fetch the range of cells A2:B3
var dataRange = sheet.getRange(startRow, 1, numRows, 100);
// Fetch values for each row in the Range.
var data = dataRange.getValues();
for (var i in data) {
var row = data[i];
var emailAddress = 'coryabaird@gmail.com'; // First column
var message = row[27]; // Second column
var subject = row[3];
MailApp.sendEmail(emailAddress, subject, message);
}
}
Okay here's that tutorial example with an EmailSent column and a couple other changes. What else would you like?
function sendEmails() {
var sheet=SpreadsheetApp.getActiveSheet();
var startRow=2;
var dataRange=sheet.getRange(startRow, 1, sheet.getLastRow()-startRow+1, sheet.getLastColumn());
var data=dataRange.getValues();
for (var i=0;i<data.length;i++) {
var row=data[i];
var emailAddress='coryabaird@gmail.com'; // First column
var message=row[27]; // Second column
var emailSent=row[?]; // fourth column
var subject = 'Sending emails from a Spreadsheet';
if(emailSent!='Sent' && MailApp.getRemainingDailyQuota()>0) {
MailApp.sendEmail(emailAddress, subject, message);
sheet.getRange(i+sr,4).setValue('Sent');
}else{
SpreadsheetApp.getUi().alert('emailSent: ' + emailSent + ', Quota: ' + MailApp.getRemainingDailyQuota());
}
}
}
Image:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.