TSR
TSR

Reputation: 20426

Send email programmatically

I wrote a custom function called sendEmails in a script linked to a google spreadsheet. It works when I run the function through the script editor, however, it does not work when I run it through the spreadsheet.

My goal is to let the spreadsheet run without having a user and send an alert (in my case an email) automatically when a condition is met on the spreadsheet's cells.

This is the not working code:

=if(V3=X3,sendEmails(),"Waiting")

The alert can be anything that I can read using my phone or another computer.

Upvotes: 1

Views: 100

Answers (2)

Jordan Rhea
Jordan Rhea

Reputation: 1206

With custom functions you are limited by the kinds of services that you can use because custom functions never ask for authentication. https://developers.google.com/apps-script/guides/sheets/functions#using_apps_script_services

You could add your function to the add-on toolbar or setup an installable trigger to run the sendEmails() function.

Here is some more documentation to help you out.

https://developers.google.com/apps-script/guides/menus

https://developers.google.com/apps-script/guides/triggers/installable

Upvotes: 2

HDCerberus
HDCerberus

Reputation: 2143

Without a look at the full list of code, it's difficult to say. Two possibilities based on your single line of code.

1) It's not enough to say =if(V3==X3) and assume that if they become equal, they will trigger. You must specify for the spreadsheet when it should check if these are equal (For example, on spreadsheet edit, or at a specified time interval).

2) In your if statement, you are specifying that V3 SHOULD equal X3, not checking if it is. =if(V3==X3) or =if(V3===X3) resolves this.

Upvotes: 0

Related Questions