Reputation: 3906
I have a Google Apps Script that contains the following code:
function onOpen() {
var emailAddress = "[email protected]";
var message = "Viewed"
var subject = "Someone Viewed Your Resume";
MailApp.sendEmail(emailAddress, subject, message);
}
I want to receive an email every time someone views my resume
But for some reason I only receive an email if I am the one open it and not when anyone else does.
What do I need to change to get the desired results?
Upvotes: 1
Views: 3153
Reputation: 45740
Your container-bound script in a shared document will only run if:
Sharing has granted edit privileges. (Viewing and Commenting aren't enough.)
User is logged in with a Google account. (Only scripts run as webapps can be triggered anonymously, at which time they run as the owner. No such option, in this case.)
User agrees to authorize the script. (A script that sends emails will require authorization.)
Since this is your resume, I think you're going to need to find another solution.
Upvotes: 1
Reputation: 440
The onOpen
trigger should run in response to the active user opening the document.
The active user is defined as:
The user (Google account) that causes a script to execute. Depending on the execution method this may be different from the effective user. You can also think of this as the user at the keyboard
Have you tried accessing the document with a dummy account?
Upvotes: 0