Created
May 18, 2017 21:14
-
-
Save alaq/e8cf8185d483ba07f3c484e29d3d6ab5 to your computer and use it in GitHub Desktop.
When run, will return in a spreadsheet the number of emails in your inbox, as well as the number of emails received the previous day. Run it with a daily trigger at 1am.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function GmailEmails() { | |
var InboxThread = GmailApp.getInboxThreads().length; | |
var today = new Date(); | |
var year = today.getYear(); | |
var month = today.getMonth() + 1; | |
var day = today.getDate(); | |
var day1 = day - 1; | |
var day2 = day; | |
var yesterdayThreads = GmailApp.search('-from:me after:' +year +'/'+month +'/'+day1 + ' before:' +year +'/'+month +'/'+day2); | |
var threadCount = yesterdayThreads.length; | |
var gmailSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Gmail"); | |
gmailSheet.appendRow([new Date(),InboxThread,threadCount]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment