NOTE: This is mac only.
- Go to Finder.
- Press CMD+SHIFT+G.
- Type
~/Library/Application Scripts/com.apple.mail. - Open
saveByRule.scptand changetheFolderto where you'd like emails to be saved. - Copy and Paste
saveByRule.scptinto~/Library/Application Scripts/com.apple.mail. - Go to Mail>Preferences>Rules>Add Rule.
- Enter some filter for your rule and choose Run Applescript as action to perform. Use saveByRule as option.
- Click Ok.
For converting to PDF and HTML.
- In the terminal, run
sudo pip install mail-parserandbrew install Caskroom/cask/wkhtmltopdf. - Open
toPDF.shand alter location to match the directory your saved emails are located. (Keep *.eml) - In the terminal, run
bash toPDF.sh.
For Automating conversion to HTML/PDF.
- Create new>Folder Action in Automator.
- Set folder to watch to folder where emails are saved.
- Add
run shell scriptaction. - Copy and paste contents of toPDF.sh into textarea of run shell script.
- Save.
NOTE: saveByRule.scpt is almost entirely copied from StackOverflow.
Anyone else experiencing an issue where the rule reverts back to the iCloud account, even when another is selected? I am trying to apply this to my Yahoo Mail account, but every time I go into the rule by choosing "edit", icloud is the selected option. I still can't get the script to actually work, and I'm doubtful this is why, but I probably do need to clear this obstacle first.
