Thursday, 21 March 2019

Email scheduler for Gmail - archive delivered

Overview blog post.

The following Google Apps Script code archives Delivered message to another sheet so that there is a permanent record of when emails were sent (as they do not appear in the Sent label of Gmail when using the scheduler) and so the main sheet does not become clogged.
Screenshoot of email entry that has been archived
Archived email
For the most part the script follows my previous blog post on archiving sheet data. A noticeable difference appears in the form of needing to count which rows have been deleted as the data all shifts (I have detailed the solution in this blog post).
There is a noticeable regular expression (regex) element which is designed to match the word Delivered encompassed by wildcards, from the Status column - as this cell will also contain the time the email was sent.
var status = emailData[i][5];
var isMatch = status.match(/.*Delivered.*/);
Logger.log('isMatch is: ' + isMatch);

No comments:

Post a Comment