NOTE: This is mac only.
- Go to Finder.
- Press CMD+SHIFT+G.
- Type
~/Library/Application Scripts/com.apple.mail
. - Open
saveByRule.scpt
and changetheFolder
to where you'd like emails to be saved. - Copy and Paste
saveByRule.scpt
into~/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-parser
andbrew install Caskroom/cask/wkhtmltopdf
. - Open
toPDF.sh
and 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 script
action. - Copy and paste contents of toPDF.sh into textarea of run shell script.
- Save.
NOTE: saveByRule.scpt is almost entirely copied from StackOverflow.
What happens if you have two different Email messages with the same message date (YYYY-MM-DD) and the same subject, @dustinknopoff ? Won’t your script cause the second Email file to overwrite the first Email file?
Perhaps you should add a counter into the loop and use that counter when forming the
newFile
value? That way when going through the loop, thenewFile
value would be different even if two Email messages had the same message date (YYYY-MM-DD) and the same subject.