Skip to content Skip to sidebar Skip to footer

OnEdit Need To Send Emails From A Column

When in column O cell is mentioned 'Shipped' I want to send emails in column C (with corresponding row) Need support to get this script right function sendEmail(e) { var thisSh

Solution 1:

See if this works:

function sendEmail(e) {
var thisSheet = e.source.getActiveSheet();
if (thisSheet.getName() !== 'CRM' || e.range.columnStart !== 15 || e.range.rowStart == 1 || e.value !== 'Shipped') return;
var body, headers = thisSheet.getRange(1, 1, 1, 15)
    .getValues()[0],
    thisRow = thisSheet.getRange(e.range.rowStart, 1, 1, 15)
    .getValues()[0];
    var recipients = thisRow[2];
    var subject = "Your Vehicle is shipped " + e.source.getName(),
    body = "Dear Customer,\n\nYour vehicle has been shipped from Japan";


MailApp.sendEmail(recipients, subject, body);
}

You didn't say how much columns you need to use to construct the body of the email but that can be easily changed if you increase the number in the while loop.


Post a Comment for "OnEdit Need To Send Emails From A Column"