I have a google apps script on a particular spreadsheet to which I have given permission to write an email from my account. A few others have 'edit' access to the spreadsheet as well. I was wondering if there is any way for me to prevent the people with 'edit' access from modifying my script and sending rouge emails from account?
I explored options such as:
- Creating a library on a personal sheet and reading the code which is being accessed by other as well. This only hides the code from others, but they can still write an email because the script area would already have had the permission to write emails.
- Creating add-ons which is what I am currently investigating.
Below you can see an example of my script which is triggered on edits inside the spreadsheet.
function onEditTrigger(e)
{
var row = e.range.rowStart;
var column=e.range.columnStart;
if (row==1 && column ==1)
{
GmailApp.sendEmail("xxx@gmail.com","Subject","Email content");
}
}
What I want to do is to send an email from my account when anyone edits the A1 cell. But I want control over what is sent from my mailbox. Currently anyone who can edit the sheet can edit the email that is sent from mailbox as well, which is what I do not like.
Can I restrict people so that they can not edit the email content from my account by exploiting the email permissions which I had originally given it.
EDIT:235325 Just to be clear, I am not worried about normal functioning of code. I just want a way of securing the script so that someone rogue with 'edit' permissions to the spreadsheet should not be able to edit my script to send any email that he/she wants .