You need to do three things; install a script, set up a mail rule, and set up folder actions.
Part 1: Install Script
Copy and paste the script below into an AppleScript editor window:
using terms from application "Mail"
on perform mail action with messagestheMessages
set attachmentsFolder to "Volumes:<name of volume:<name of folder>:" as rich text
--remove the angle brackets, but keep the colons, including the last one
tell application "Mail"
set selectedMessages to theMessages
try
repeat with theMessage in selectedMessages
repeat with theAttachment in theMessage'smail attachments
set originalName to name of theAttachment
set savePath to attachmentsFolder & originalName
savetheAttachmentinfilesavePath
end repeat
end repeat
end try
end tell
end perform mail action with messages
end using terms from
Save this script with a name like 'CopyAttachments' in
~/Library/Application Scripts/com.apple.mail
(note:
~/Library means your user library. You can find it by triple-clicking the path above, then control-click on the highlited texgt and choose Services > Reveal in Finder
)
Part 2: Set up Mail Rule
Open Mail.app. Click on your Inbox in the sidebar. Click ‘Mail > Preferences... > Rules > Add Rule'
Under ‘Description’ give the rule a name (e.g., ‘Copy attachments’)
Set ‘If ANY of the following conditions are met:
to
‘From contains’
and the email address of the person whose attachments you want to target.
(note:
You can add more than one person’s email if you wish, but you do so by hitting the ‘+’ key and adding a new condition, not by adding more than one address in the text field. Each text field must contain only one condition (i.e., email address or keyword).
)
Next, set ‘Perform the following actions:’
to
‘Run AppleScript’
Click the ‘No Script Selected’ button and choose ‘CopyAttachments’
Click ‘OK” and in the following dialog click ‘Apply’.
3. Create & Set up a Folder Action
Open ‘Automator.app’. From the open panel choose ‘Folder Action’.
In the large, empty panel at the top you’ll see
Folder Action receives files and folders added to Choose folder
Click the ‘Choose folder’ menu, choose ‘Other’ and select the folder you want the attachments to be saved in.
In the filter/search bar on the left of the Automator window, type ‘print images’. Drag the ‘Print Images’ selection from the results list into the middle of the empty workflow and release.
You can set some options here if you like (‘scale to fit’ might be useful).
You can choose either ‘Default Printer’ or click to select your actual printer. If your actual printer is the default, it won’t make any difference.
Press ‘command-S’ on your keyboard to save. Supply a name (e.g. Print PDFs) and hit ‘OK’. You do not choose a save location.
Quit Automator.
Open a Finder window and navigate to the folder where the attachments are going to be saved.
Hold down the ‘control’ key on your keyboard and click the attachments folder. From the contextual menu, go to ‘Services > Folder Actions Setup…' and click to open the dialog box.
Navigate down the list of scripts till you see the name of the Automator action you saved above and select it. Click ‘Attach’.
In the parent dialog box, check the box at the top that says ‘Enable Folder Actions’ and ensure that in the list on the left the attachments folder is listed and checked. Check that on the right, the ‘Print PDFs.workflow’ is checked.
If all is in order, close the dialog box. The procedure is complete and the workflow is installed.
It'd be wise to test the script as soon as possible. If it fails to work, double check that you've entered the correct path in the AppleScript as that's the most likely point of failure.