A
A
Alexander2021-11-05 15:25:27
Google Apps Script
Alexander, 2021-11-05 15:25:27

How to automatically send emails from Google Sheets by condition?

You need to set up a script that will run every minute through a standard trigger and check, for example, column A, if the value in the line is "New", then these lines are sent by mail using the script, and then change the cell value to "Sent".

Those. with a new trigger, there may be 0.1 or more rows with the value "New", you need to send these rows and change the value to "Sent".

How to write such a script?

For now, there is such a script that works when manually started.

function sendSelectedEmails() {
var sheet = SpreadsheetApp.getActiveSheet();
var activeRange = sheet.getActiveRange();
var data = activeRange.getValues();
for (i in data) {
var row = data[i];
var emailAddress = "ХХХХХХХХХХХХ@gmail.com";
var subject = "ХХХХХХХХХХХХ";
var message = row[0];
MailApp.sendEmail(emailAddress, subject, message);
}
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Grigory Boev, 2021-11-05
@ProgrammerForever

It has already been , look - several options have been proposed

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question