1

I have a Google Sheet which sends an email after a specific column has been edited from a trigger. The script works correctly, the problem is that it always sends from my email address (the creator of the trigger). Is it possible to send the email based on a field, not based on who updated the sheet or who created the trigger? So if 1 column is the email address, if that row is updated, it sends from that email. All of these would be enterprise email addresses. My current script is below:

function sendEmails(e) {

    var sheet, v, emailAddress, subject, message, time;

    sheet = e.source.getActiveSheet();
    if (sheet.getName() !== 'Kanban Board' || e.range.columnStart !== 2 || e.value !== 'Done') return;
    v = sheet.getRange(e.range.rowStart, 1, 1, sheet.getLastColumn())
        .getValues()[0]

    emailAddress = 'email1@gmail.com';

    time = Utilities.formatString("%07.0f", v[7])

    subject = 'Ticket:' + v[8] + ' Action:TechUpdate Hidden:NO Status: EmailClient:NO Reassign: MinutesWorked:' + time + ' BillingRate:';
    //subject = 'Ticket:8924'  + ' Action:TechUpdate Hidden:NO Status: EmailClient:NO Reassign: MinutesWorked:' + time + ' BillingRate:';
    message = 'The task ' + v[5] + ' has been completed.' + v[2];
    MailApp.sendEmail(emailAddress, subject, message);
}
marcolz
  • 2,880
  • 2
  • 23
  • 28
Daniel J
  • 21
  • 3
  • I think its answered by this http://stackoverflow.com/questions/15697291/google-script-mailapp-sendemail-only-works-with-my-email-address?rq=1 – farrellmr Jan 12 '17 at 20:52
  • The common response I've seen is "maybe not." I could see where issues may arise with sending from a non-Gmail address, but these would all be related to our institutional accounts. It would likely be the same 4-5 users that I would be sending emails from...so even if they only had to authenticate their email once, that could work. – Daniel J Jan 13 '17 at 04:22

0 Answers0