Automation for labeling Gmail threads related to NAHS & NAMS Cognos Attendance/Enrollment reports. This script addresses a limitation of Gmail filtering that doesn't filter emails when the subject is the same, but the attachments have different names. For example, if an email's subject is, "A new version of My Alt HS Attendance/Enrollment Count is available", but the attachment is named either "My Alt MS Attendance/Enrollment Count" or "My Alt HS Attendance/Enrollment Count", this script will look at the title of the attachment and add the appropriate label to the email.
labelCognosReports()
- Searches unread threads matching the report subject and applies a label depending on attachment file name.
- Moves threads to archive and marks them as read.
- Open the Google Apps editor for this project,
- Select the Triggers icon,
- Click on the blue + Add Trigger button on the bottom right,
- Create a separate trigger for each day of the week you want the function to run (i.e., Mon-Fri)
Make the following selections under each of the following headings:
labelCognosReports
Head
Time-driven
Week Timer
If you intend to run this script every day of the work week, start with Every Monday
, then when you create the next four triggers pick the following day of the week.
Choose which ever time block you want the script to run.
- Click
Save
- Create another trigger for the following day of the week. Do this until you have created all five triggers, one for each day of the week.
- Open the Apps Script editor for this project,
- Choose
labelCognosReports
from the function dropdown, - Click Run, then view logs under Executions.
- Labels are created on-the-fly if they don’t exist.