Blog Archives

how to save and print email attachments

I was recently asked for a script that would automatically save and print all the pdfs from one particular client’s emails. Since this is quite a common use case (think invoices from a particular supplier, for example) and involves a fair bit of complexity, I thought I’d share the answer for any others out there that have the same need.

We’re going to need to do three things; install a script, set up a mail rule, and set up folder actions. Here we go!

Part 1: Install Script

Copy and paste the script you see below from here:

save mail attachmentsSave this script with a name like ‘CopyAttachments’ in

~/Library/Application Scripts/

(note: ~/Library means your user library. You can find it by triple-clicking the path above, then control-click on the highlighted text and choose Services > Reveal in Finder)

Part 2: Set up Mail Rule

Open 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’:


‘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:’


‘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 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. 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. Let’s suppose your hard disk is called ‘Macintosh HD’, your user name is “Mack” and the folder you want to save the attachments in is “Invoices From Acme”, then the set attachmentsFolder line should look like this:

set attachmentsFolder to "Volumes:Macintosh HD:Users:Mack:Invoices From Acme:" as rich text

You must ensure you’ve already created the folder ‘Invoices From Acme’ before running the script. Also, be sure you don’t forget the trailing colon at the end of the path and that you have a matching pair of opening and closing quotes around the path name.

Any problems, drop me a comment below and I’ll try to help you out. Good luck and enjoy! 🙂


draft message crashes Mail

Mail 2_512x512

If you try to create a message with a corrupted or oversized attachment (suspect anything over 10MB), you might find that Mail keeps crashing every time you try to start it. This problem can be particularly annoying since you often can’t even get Mail open long enough to delete the problem message. Worse, even when you delete the problem message or attachment, it can just come straight back as soon as you try to refresh your messages from your web-based IMAP mail server. If this problem’s happening to you, here’s the solution.

First of all, disconnect from the internet and then quit Mail.
If you’re using 10.7 or later, click on Finder, choose ‘Go’ in the menubar and hold down the ‘option’ key. Choose ‘Library’ from the menu. For users of OS X 10.6 or earlier, navigate to

HOME > Library

in Finder.

Once you’ve found the user Library folder (note: this is not the same as the root or system library folder!), navigate to


In there you’ll see some folders called things like


for each email address you have. In each one there is a Drafts folder. Locate the correct one and delete the file.
Do NOT restart Mail, but open your internet connection, go to your web-based email through your browser and delete the draft from there too.
Now you can restart Mail. Choose ‘Rebuild’ from the Mailbox menu in the menubar.

Problem solved! 🙂

featured picture: ‘Mail – flurry style’ by Lukeedee

change Flag names in Mail

‘Red’, ‘Green’ and ‘Yellow’ aren’t particularly meaningful ways to categorise messages, but changing the names to something more useful can make the ‘Flags’ feature a handy tool.

The procedure is quite simple, but the first thing you have to do is actually flag a couple of messages:

1. Flag some messages (one of each colour if you want seven categories):

2. Next, go into the sidebar in Mail. Click the little disclosure triangle:

3. Click on one of the names and press ‘return’ on the keyboard:

4. Type in a new name and press ‘return’ again:

5. Of course, you can change the flag names at any time:

how to make your battery last a bit longer

Here’s a couple of tricks you can use to eek a bit more life out of your old battery between recharges.

1. Turn off the keyboard backlights by pressing F5.

2. Turn off Bluetooth in the menu bar.

3. If you’re not using the Internet, turn off Wifi in the menu bar.

4. If you are using the internet, but you’re not expecting or bothered about receiving mail for a time, quit Mail or any other email client app. If you still want to check your email and you use a web-based mail service like GMail, you’ll use less battery power if you quit Mail, and open GMail directly in your browser window.

5. Reduce the hard disk drive sleep time (formerly known as ‘spindown’). By default, your Mac will power down the hard disk after 10 minutes inactivity on battery power. You could try setting that to 5 minutes (any less, and you’ll probably lose what you gain as the the HD will end up having to power up more often than necessary).

To do so, open Terminal, and copy/paste this command:

sudo pmset -b disksleep 5

After pressing ‘Return’ on your keyboard, you will need to enter your password, which will be invisible when you type it (so type carefully).

If you want to change it back to its default anytime in the future, just use the same command but change the ‘5’ to ’10’.

 This doesn’t affect the spindown time when you’re on mains power.

how to restore Bounce in Mail

If you were a fan of the ‘bounce’ feature in the previous version of Mail, you may be disappointed that it has been removed in Mail Version 5.x

If you want the feature badly enough, you can either

1. Use this add-on for in Lion
Restore Bounce Mail Button To Lion’s Mail


2. Use Mozilla’s instead of Mail, and get the ‘Mail Redirect‘ add on.

Mail won’t remember passwords

Sometimes, Mail keeps asking you for a password that you know it already has. It asks if you want it to remember the password in the keychain, and you say Yes! And still, you keep getting those password requests…

If you look in Mail > Preferences… > Account Information, you may be surprised to find the password field blank. You may be even more surprised that when you enter it, click out of the tab and hit ‘Save’, the field is blank again the next time you look!

There are a couple of different solutions to this problem, and both revolve around the keychain. One solution is to try a keychain repair. If the repair indicates nothing is wrong, then you have a problem with the access controls. Let’s deal with each in the order you should do them.

Verify and Repair Keychain
1. Go to Applications > Utilities > and double-click to open it.

2. From the menubar, choose Keychain Access > Keychain First Aid

3. Type in your admin password in the field, and click Start to verify the keychain. If the keychain needs repairing, click the radio button for repair and click Start again. Run the ‘Verify’ task one more time.

Repair Access controls
If the above didn’t solve your problem, or the keychain verify/repair task indicated no problems, then you’re going to need to look at the access controls on each Mail keychain.

4. In the left-hand pane, click login in the top panel, and Passwords in the bottom panel.

5. Look for your Mail/imap keychains. Click on one of them, and then press command-i on your keyboard, or click the little ‘i‘ at the bottom of the Keychain window.

6. Click the Access Control tab in the window that pops up. Click ‘Confirm before allowing access’, and make sure Mail is in the list of apps in the window underneath that is always allowed access. Go and do the same for any other Mail/imap keychains in the window, and your problem should be fixed.

7. If the settings above were already configured correctly or they do not resolve the problem, click on the Attributes tab (next to the Access Control tab).

8. Click on the ‘Show password’ box. If everything is OK, you should get a request to put in your admin password. Chances are, though, if you’ve got to this stage you will instead get a message saying ‘Access is restricted’ and no option to do anything about it.

9. If you don’t get asked for the password, close the information box (red radio button, top-left), and control-click on your mail/imap keychain in the Keychain window. Choose ‘Delete <name of keychain)'. Do the same for any other keychain's exhibiting the same problem.

10. You can now go back to Mail, and enter your password in the Account preferences box.

Problem solved! 🙂

Mail: back to classic

OK, I gave it three days, but in the end I just can’t get along with Mail’s new look; it’s just too visually confusing for me. The good news is Apple didn’t desert its old users entirely. If you want to return Mail to its former glory, just go to Mail Preferences > Viewing and check the box at the top. That’s it, back to clarity! 🙂

Mail Preferences:classic OS X mail view

%d bloggers like this: