Automatically Print Attachments in Apple Mail

Mar 14, 2008

Having spent hours scouring the Internet for someone who had already solved the problem of "how to automatically print attachments from Apple Mail," I found no answers. In fact the following Google Search "print attachments" apple mail applescript yielded only 7 results on October 7, 2007.

In my case the reason I wanted to do this is that I get my faxes sent to my email from an online fax service. I currently use Send2Fax.com, but have used eFax in the past. The faxes are sent to a separate email account I have set up specifically to receive faxes. Then I have to open the message, open the attachment, and print. Very redundant. My laziness demands an easier way.

I searched the forums. Automator actions and workflows, Applescript resources, etc.

After stepping back a little I started thinking along new lines. How about I save the document what are my options then? I came up with a jury rigged method of using folder actions along with auto saving of the attachments.

I made a destination folder, and attached an applescript to it to try and print the document with Preview. However to my utter surprise I found out that Preview is not scriptable.

Hours more spent in trying to figure out how to make Preview scriptable came up with the following command to enable the Standard Suite for Preview:

defaults write /Applications/Preview.app/Contents/Info 
NSAppleScriptEnabled -bool YES

However this still didn't solve my problem.

Then I remembered years ago discovering that PDF files can be printed from the command line using "lp" a little command line utility for printing inside a terminal shell.

I am not going to go into that here, but that is the only thing that was able to get me moving back in the right direction.

I found a script in my system library for saving images as a JPEG which I altered to simply use "lp" to send the document to my printer.

Then I found a script here:

That I altered to save my attachments automatically for me in the folder with my action attached to it and bam! My faxes now print automagically.

You could use this for any file that can be printed with "lp".

The Steps are:

  1. I created a folder for my faxes:
  2. ~/Faxes
  3. I right clicked on the folder to enable folder actions as explained here
  4. Then I saved this script in "~/Library/Scripts/Folder Actions"
  5. This was a script I modified from the provided folder action "Image Ð Duplicate as JPEG.scpt" which you can find at: "/Library/Scripts/Folder Action Scripts"
  6. And then attached this script to the folder using the above instructions.
  7. Next I saved this script in "~/Library/Scripts/Applications/Mail/"
  8. This is the script I modified from here
  9. Then came the set up in Apple Mail.
  10. I created a rule:
  11. All conditions met
  12. Any Attachment Name - Contains - ".pdf"
  13. Account - myfaxaccount@faxaddress.com
  14. Run Applescript - "~/Path/to/script"
At this point everything worked for me. If you are in need of this feel free to give it a try and see if it works for you. Some interesting links I came across when trying to figure this all out:

Update

The problem is that line 45 should read like this:

if (every mail attachment of theMessage) ≠ {} then

the not equal sign is not showing up in the text.

I have placed a copy of the script in script editor format here.

Filed under: /applescript

permanent link

Recently Added Files

A_New_Era_of_Responsibility2.pdf
ForeclosureReliefPlanProposal.pdf

An outline of ideas I have had on ways to help stem the accelerating decline of home prices and the increase in foreclosures.

hpimonthly122308.pdf

The monthly Housing Price Index for the year end 2008.

01 Tue, November 25th, 2008 Hour 1.mp3

Economic Meltdown & Solution 1

02 Tue, November 25th, 2008 Hour 2.mp3

Economic Meltdown & Solutions 2

Links on the Web

Time Machine Backups
What the Price of Gold Is Telling Us
Too old to care for their grandchildren.

How crazy a world when the State can take children away from their family because they are too old. I mean 46? Really that is not much older than LiAnne; not much older than my mother when she had her last child; and not much older than LiAnnes mother when she had her last. Crazy. { Read More }

Buy American.

Astronomy Photo of the Day

Mount Rushmore s Starry Night

This starry night sky sparkles above the Black Hills This starry night sky sparkles above the Black Hills


Perihelion and Aphelion

This year Aphelion, the point in Earth's This year Aphelion, the point in Earth's


Lyman Alpha Blob

Dubbed a Lyman-alpha blob, an enormous cloud of hydrogen gas spans Dubbed a Lyman-alpha blob, an enormous cloud of hydrogen gas spans


Three Galaxies in Draco

This intriguing trio of galaxies is sometimes This intriguing trio of galaxies is sometimes


The North America and Pelican Nebulae

Here are some familiar shapes in unfamiliar locations.  Here are some familiar shapes in unfamiliar locations.


Torture: The Golden Rule?

Everyone seems to be falling into Dick Cheney's trap of trying to determine if the waterboarding was "effective." This should never even be a consideration. If our enemies stared waterboarding our troops, if our troops were detained by Al Qaida and treated the same way we treat our detainees, the pitchforks would be out screaming for napalm, nukes or whatever the next level of escalation called for.

What happened to the Golden Rule I try hard to teach my 2 and 5 year olds?

When did it become OK to do wrong to another as long as they are weaker than us and it benefits us or our friends?

Once the morality of the issue is established, the other questions of effectiveness are invalidated as a political smoke screen to prevent justice and the catharsis needed for our country to forgive ourselves for our tragic offenses to humanity.

When people try to put up the political smoke screen blow it away so we can see the fetid heart of our own national fear. It is the only way we can heal.

Please don't let politics, or obscure concepts of legalizing evil, keep us from moving forward as a nation and healing the wrong that has been set in motion by the Bush War of Terror.

Jon Stewart - Bailout Blues

This funny rant at cable network finance reporting speaks directly to the emotionally charged way most of us get out news. Where is all this money coming from and where is it going?


Latest Posts from Life Hacker

Tips, Projects, and Great Eats for Your Fourth of July Weekend [Summer]

Whether you're just grilling, picnic lunching or heading out on a wilderness excursion for the holiday weekend, we've got a few recipes, projects, and ideas to run by you, cultivated from years of gathering clever outdoor hacks.

Photo by Nicholas_T.

It's by no means exhaustive or conclusive, but we wanted to provide an overview of some of the most clever or handy stuff we've seen involving nature's wonder and the great outdoors, along with its sometimes unpleasant side effects. Check out what interests you, get inspired for the weekend or a better-planned one, and, please, tell us what you're going to be doing outdoors this weekend, and how you're doing it, in the comments below. In the meantime, click through to the galleries to enjoy some of our favorite tips, projects, and food fun for your time outside this Fourth of July Weekend.

Click through on any of the images below for the full goods.

Lotions, Repellents, and Antidotes

We're talking homemade insect repellent, bug bite relief, and choosing the right sunblock.


Camping and Surviving

Start a fire with your cellphone, build a great campfire, tie killer knots, and more.


Outdoor Projects

Build an outdoor movie theater, a handy beverage barge for poolside fun, and then some with a few fun outdoor DIYs.


Summer Drinks

From better lemonade to beer cocktails to cold soda fast, we can quench that thirst.


Summer Eats

Avoid picnic disasters, grill the perfect burger, get to know your edible outdoor greens, and oh-so-much more.



Talking Heads

Which Al Franken will show up in Washington?

July 1: Almost eight months after Election Day, the Minnesota Supreme Court declares Democrat Al Franken winner of one of the state’s U.S. Senate seats, giving Democrats the ability to overcome filibusters. NBC’s Pete Williams and Chuck Todd report. (Today Show)Al Franken arrives in Washington next week to claim a seat that stood vacant for half a year — but will he be the passionate, sometimes angry liberal or the cautious, serious politico?




Email this Article Add to Newsvine

Health overhaul means big Medicare changes

If you're not a Medicare recipient, your parents probably are, or soon will be. And you yourself will be on Medicare eventually. That’s a reason to pay attention as Congress debates an overhaul of health insurance.

Email this Article Add to Newsvine

Palin shocker a boon to her lieutenant

Whatever other motivations she had, she gave top Republicans in Alaska and Washington virtually no warning of her plans.

Palin resignation splits GOP

Skeptics say Palin diminished presidential hopes.

Enquiring Minds Want to Know

THRUTH ABOUT AREA 51

Area 51 is one of the areas which is among the top no-go areas in the world. It seems that our government is trying to hide something from the public. Maybe it could be high tech aircrafts,...

The Natural Revolution: Iconic skyscrapers find new luster in green tech
New from israel

Hey im NoamC from Jerusalem, Israel. Ive been reading ATS almost daily for years, and finally im part of the community=)

7/7 Conspiracy main-stream again

I may have missed this being posted elsewhere but could not find it in a search.... It seems the 7/7 even in London is gaining momentum with the conspiricy theory after a good...

The IRS is a privately owned company based out of Puerto Rico

I started posting this info in another thread but there is so much info I didnt want to hijack it. So I started this one. I know some of tis is old news to some of you but the youngens...

Technobable

World

MI6 chief blows his cover as wife's Facebook account reveals family holidays, showbiz friends and links to David Irving


The new head of MI6 has been left exposed by a major personal security breach after his wife published intimate photographs and family details on the Facebook website.

'There's so much smoke in here... we can't get out': Desperate last phone call of mother who died in tower block blaze with her two children


A young mother who died with her two toddlers in the South London tower block inferno made a desperate last phone call to neighbours as smoke engulfed them.

Sarah Brown's tears for Gary McKinnon: PM's wife backs Mail campaign to stop extradition of Pentagon hacker


Sarah Brown, the Prime Minister's wife, wept yesterday as she pledged her support to Gary McKinnon's mother Janis Sharp.

Charles' heartbreak: Royal salute, but was Colonel R left vulnerable to Taliban bomb?


The Prince of Wales spoke yesterday of his heartbreak and horror at the loss of the most senior British officer to die in Afghanistan.

Let's just make the licence fee a tax: BBC boss says cost of watching TV might be put on council bill


Mark Thompson’s comments have been taken as an admission that the growing use of new technology to watch programmes will make the licence fee obsolete.

Currency Trading

South East Asia

Noppawan wins Wimbledon crown

London - 18-year-old Noppawan "Nok" Lertcheewakarn won the girls' singles championship at Wimbledon, the first Thai ever to take a title at the fabled championship.

UN chief chides Burma over Suu Kyi visit

UN Secretary General Ban Ki-moon delivered a stern rebuke to Burma's junta Saturday after the country's military ruler refused to let him meet detained pro-democracy leader Aung San Suu Kyi.

Twitter Status

Sideblog

# Get HTML Body Contents

#!/usr/bin/perl my $contents; while ( chomp; $contents .= $_; } $contents =~ s/(\)(.+?)(\.*)/$2/gs; print $contentsmore.

Apache's AliasMatch Directive

When using Apache's AliasMatch directive I found that if you don't terminate your regular expression your redirect can enter an infinite loop causing infinite redirects to somthing like: http://wwwmore.

A Quick and Easy Password Generator

This short tutorial shows you how to quickly generate a list of passwords using /dev/urandom, and uuencode. more.

The virtual machine could not be started. An unexpected error occurred.

I was having a problem with my VM not restarting after my Domain Controller required me to change my password. I kept getting the errors discussed in this email thread "The virtual machine could nmore.

Enable Network Volumes for Use in Time Machine.

The following works for me in OS X Leopard, not sure about other versions. If you need to use a network drive like those available through your AirPort Extreme, you can execute the following commanmore.

Enable mounting of remote CD/DVDs on any Mac

I came across this article that explains how to enable the remote DVD mounting available to MacBook Air on any Mac using Leopard.more.

Convert Rich Text Files to HTML

The following works in Mac OS X to convert an RTF document to an HTML document. textutil -stdout -convert html [filename] The utility takes a file in and outputs to standard out. This is good for more.

Extracting the contents of BODY tags for HTML documents.

I often need to get the contents of the body tags in HTML documents. That is the contents of the body tag without the actual body tag itself. This is useful in conjunction with a blosxm site for insmore.

Install cygwin cron via cron-config script

The following was the steps I took to install cygwin cron in WinXP SP2. Note that the value of CYGWIN should be exactly "ntsec", you can't enter "netsec tty". Also, the /etc/passwd and /etc/group shoumore.

Keep Your Drive Alive

To keep a lamp burning, we have to keep putting oil in it. --Mother Teresa (1910-1997) Indian missionary, --Nobel Peace Prize winner At first glace the quote by Mother Tmore.