I have a spreadsheet with a list of email addresses and personalized content to send each day. I setup a google apps script to grab the data and send the emails and I'll use a time based trigger to run it daily.
What I still need is to return into the spreadsheet for each row that the mail successfully sent (have the responseCell value set with the currentdate) and I can't seem to find how to do that.
Here's what I have but I can't find how to setup a success handler for the mail send process to wrap that setValue in. Closest I found is to use the GmailApp function to search the sent folder but I'm sure there's a more elegant way to solve this.
function sendEmails() {
var sheet = SpreadsheetApp.getActive().getSheetByName("List of kids");
// Fetch the range of cells A2:Fmaxrow
var dataRange = sheet.getRange(2,1,sheet.getMaxRows() -1, 6);
// Fetch values for each row in the Range.
var data = dataRange.getValues();
var todayis = Utilities.formatDate(new Date(), "GMT+3", "dd/MM/yyyy");
for (var i in data) {
var row = data[i];
var emailAddress = row[2]; // First column
var message = row[4]; // Third column
var subject = row[0] + "\'s health declaration for " + todayis;
MailApp.sendEmail(emailAddress, subject, message);
var responseCell = sheet.getRange(2+Number(i), 6);
responseCell.setValue(todayis);
SpreadsheetApp.flush();
}
}
I believe that is not doable at the present. May be in future updates it might be possible.
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.