I am using a Google Form to amalgamate multiple messages into one daily email sent using scripts and a daily timed trigger (code copied from here and my version below).
It all works with one little bug. I get about 2/3rds of the emails also appearing in my inbox and filling it up each day.
So as an example one email address is [email protected] and they get the email, but in my inbox ([email protected]) is an email sent to [email protected] but not a forwarded message or a reply.
Any ideas how to stop this?
/**
* Sends emails with data from the current spreadsheet.
*/
function sendEmails() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Email Info');
var startRow = 1; // First row of data to process
var numRows = 18; // Number of rows to process
// Fetch the range of cells A2:B3
var dataRange = sheet.getRange(startRow, 1, numRows, 18);
// Fetch values for each row in the Range.
var data = dataRange.getValues();
for (var i in data) {
var row = data[i];
var emailAddress = row[0]; // First column
var message = row[1]; // Second column
var subject = 'Tech Support Handover';
MailApp.sendEmail(emailAddress, subject, message);
}
}