Google Gmail  Missing Email Alert Script  

Google Sheet Script to send an email notification alert if you have not received an expected email message in xx number of days.

If you find this Google Script useful, please consider making a donation https://Payments.Baumbach.com



Script missing email notification

I receive so many emails for online payments due, backup reports, battery UPS backup test reports, room temperature monitor reports, etc. Sometimes I do not know if any of these systems failed to send an email message like they should have, I never know what emails I am missing. This script reminds me that I have not received a particular email that I was expecting or should have received.

To get a copy of this Google Sheet and script CLICK HERE You need to be logged in to your Google account. Opens in new window. Select Make a copy.

If you need help on how to use this script, visit https://developers.google.com/apps-script/your_first_script

function SearchEmail() {

var sheet = SpreadsheetApp.getActiveSheet();

var data = sheet.getDataRange().getValues();

for (var i = 1; i < data.length; i++) {

// "in:all " searches trash and spam email folders. Remove "in:all " + to only search all mail and inbox

var gsearch = "in:all " + "from:(" + data[i][1] + ") to:(" + data[i][2] + ") subject:(" + data[i][3] + ") newer_than:" + data[i][4] + "d";

var threads = GmailApp.search(gsearch, 0, 1);

if (threads.length == 0) {

var emailSubject = "No email in " + data[i][4] + " days: - " + data[i][5];

var emailText = "Note: " + data[i][5] + "\r\n\r\nSearch was: " + gsearch;

var emailTo = data[i][0];

MailApp.sendEmail(emailTo, emailSubject, emailText);

        }

    }

}

Information about the missing email notification Google Script

Create a new Google Sheet, and add the above code to it under the menu EXTENTIONS / APPS SCRIPT

Sheet cells:
You can use any names that you want, but they must he in this exact order. i.e. 

A1=Send To
Must be the email address to sent the notification to.

B1=From
Must be the email address that the missing email is from.
Supports any combination of, FROM: email address TO: email address, or email SUBJECT. Use an "*" asterisk to indicate anything. Do not leave any blank rows.

C1=To
Send email notifications to any email address, or multiple email addresses, comma separate, i.e. Send To "email-one@domain.com,email-two@domain.com"

D1=Subject

E1=Notify After Days

F1=Note
used in the subject line of the email alert you receive. i.e. "Have not received an email from mom in xx days"

Configure script to run once per day
or ever how often you want. Using time trigger in Google Scripts.

I would leave line 2 as is, that way you will receive an email notification alert every day letting you know the script ran successfully.

Script written by Ken. for William April 2013.

Anther Google Sheet Script you might like. Email notification to you or other email addresses when a file in a Google folder has been added, or modified. Click here

If you find this Google Script useful, please consider making a donation https://Payments.Baumbach.com