Skip to content
Advertisement

Checking if an email is valid in Google Apps Script

I’m using the built-in api for scripting against Google Spreadsheets to send some booking confirmations, and currently my script breaks if someone has filled in an invalid email. I’d like it to just save some data to a list of guests that haven’t been notified, and then proceed with looping through the bookings.

This is my current code (simplified):

JavaScript

According to the documentation the only two methods on the MailApp class are to send emails and check the daily quota – nothing about checking for valid email addresses – so I don’t really know what criteria must be fulfilled for the class to accept the request, and thus can’t write a validation routine.

Advertisement

Answer

Stay calm, catch and log the exception and carry on:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement