Every six hours, labels the inbox mail from the senders and subjects you nominate and archives it out of the way.
Uses
Gmail
Clear the mail you never read out of your inbox
Every six hours, the workflow searches your Gmail inbox for the senders and subject words you nominate, labels each matching message and archives it out of the inbox. You decide what counts as clutter by sender address, by subject word, or both.
Nothing is ever deleted. Archiving only takes a message out of the inbox, so it stays in All Mail, and because every message is labelled first, one search brings the whole lot back if a rule proves too broad. Rules match whole values, not loose text: a sender rule matches that exact address and ignores lookalikes, and a subject word matches only as a whole word, so 'sale' clears 'Weekend sale' but leaves 'Wholesale pricing' alone. One run archives only a small batch, so a mistyped rule cannot empty your inbox before you notice, and a message that cannot be read is left in place and noted.
The label is created the first time it is used, so all you need beforehand is a Gmail account and a list of the senders or subject words to clear.
clutterSenders to blank.Set clutterSenders to blank.clutterSubjects to blank.Set clutterSubjects to blank.labelName to blank.Set labelName to blank.maxToArchive to 25.Set maxToArchive to 25.inboxScanLimit to 50.Set inboxScanLimit to 50.punctuationMarks to [!, ?, :, ;, ,, ., (, ), [, ], , ', |"].Set punctuationMarks to [!, ?, :, ;, ,, ., (, ), [, ], , ', |"].senderRules to an empty list.Set senderRules to an empty list.rawSender in clutterSenders split by ,:For each rawSender in clutterSenders split by ,:rawSender lowercase and save it as senderRule.Make rawSender lowercase and save it as senderRule.senderRule isn't emptyIf senderRule isn't emptysenderRule to the end of senderRules and save it as senderRules.Add senderRule to the end of senderRules and save it as senderRules.subjectRules to an empty list.Set subjectRules to an empty list.rawSubject in clutterSubjects split by ,:For each rawSubject in clutterSubjects split by ,:rawSubject lowercase and save it as subjectRule.Make rawSubject lowercase and save it as subjectRule.subjectRule isn't emptyIf subjectRule isn't emptysubjectRule to the end of subjectRules and save it as subjectRules.Add subjectRule to the end of subjectRules and save it as subjectRules.searchTerms to an empty list.Set searchTerms to an empty list.searchSender in senderRules:For each searchSender in senderRules:searchSender to the end of searchTerms and save it as searchTerms.Add from:searchSender to the end of searchTerms and save it as searchTerms.searchPhrase in subjectRules:For each searchPhrase in subjectRules:@searchPhrase to the end of searchTerms and save it as searchTerms.Add subject:@searchPhrase to the end of searchTerms and save it as searchTerms.searchTerms is emptyIf searchTerms is emptyinboxSearch to {searchTerms joined by a space}.Set inboxSearch to {searchTerms joined by a space}.inboxSearch. Save it as inbox.List emails matching inboxSearch. Save it as inbox.candidates to inbox.emails.Set candidates to inbox.emails.labelName and save it as label.Trim labelName and save it as label.archivedCount to 0.Set archivedCount to 0.message in candidates:For each message in candidates:archivedCount is greater than or equal to maxToArchiveIf archivedCount is greater than or equal to maxToArchiveclutterErrorIf a step below fails, save the error as clutterErrormessage.id and save it as messageId.Trim message.id and save it as messageId.message.from and save it as fromHeader.Trim message.from and save it as fromHeader.senderAddress to fromHeader.Set senderAddress to fromHeader.fromHeader contains <If fromHeader contains <fromHeader split by < split by > and save it as senderAddress.Get the first item of the last item of fromHeader split by < split by > and save it as senderAddress.senderAddress lowercase and save it as senderAddress.Make senderAddress lowercase and save it as senderAddress.message.subject lowercase and save it as subjectText.Make message.subject lowercase and save it as subjectText.mark in punctuationMarks:For each mark in punctuationMarks:mark with in subjectText and save it as subjectText. Replace mark with in subjectText and save it as subjectText.paddedSubject to subjectText .Set paddedSubject to subjectText .senderRules includes senderAddress and save it as matched.Check whether senderRules includes senderAddress and save it as matched.phrase in subjectRules:For each phrase in subjectRules:paddedSubject contains phrase (ignoring case) If paddedSubject contains phrase (ignoring case)matched to true.Change matched to true.matched is yesIf matched is yeslabel to email messageId.Add label label to email messageId.messageId.Archive email messageId.archivedCount.Add 1 to archivedCount.clutterError as text.Show in the output: Left one message in the inbox because it could not be read: clutterError as text.archivedCount as text message(s). Nothing was deleted - search for the label to review what was cleared or move any of it back.Show in the output: Labelled '@label' and archived archivedCount as text message(s). Nothing was deleted - search for the label to review what was cleared or move any of it back.