-
download and save the scripts to ~/Library/Application Scripts/com.apple.mail
-
open Preference in Mail, click on Rules
-
Find the rule you want to attach the script, and double-click the rule to edit
-
in "Performing the following action:" section, click the "+" button to add an action
-
select "Run AppleScript" in the first drop-down menu
-
select the script you intend to use in the second drop-down menu.
For collecting the subjects of all the emails matched by the rule, and save them into a csv file
References:
Applescript & Rules in Mail - Stack Overflow
Applescript: “File Already Open” when writing to new file - Stack Overflow