1

I made a Google script that sends data via mail based on a Google sheet. This sheet has many contributors so I don't know how to make the script to send that mail based in a different account.

Example:

User1 - Admin of the sheet (owner)
User2 - Contributor on the sheet (secondary user)

So I want the button that run my script send the email from the secondary user email, doesn't matters who click the button it will only send the email from the secondary user.

function email(){
   var rng = SpreadsheetApp.getActiveSheet().getActiveRange()
   var data = rng.getValues()[0];
   GmailApp.sendEmail(data[1], data[0], data[2], {htmlBody: '<h1>Hooola</h1> 
   sdfs'});
}

Here is my JavaScript function, I want to use the sendemail function using that secondary user (which I have access to it)

Thank you for your help.

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
JDLR
  • 520
  • 1
  • 4
  • 20
  • I assume you have to authenticate with the Gmail API somehow before sending emails, are you authenticating as the second user before sending the email? – Andrew Lohr Jan 15 '19 at 15:35
  • Related: https://stackoverflow.com/a/52787692 – TheMaster Jan 15 '19 at 18:09
  • When you say you have access to the secondary user, do you mean that you're authorized to send mail from that account? Does it show up if you run `getAliases()`? (https://developers.google.com/apps-script/reference/gmail/gmail-app#getAliases()) – Jesse Scherer Jan 16 '19 at 18:02

0 Answers0