|
|
Auto print Mail.app PDF attachments? Need your help
|
|
|
|
Addicted to MacNN
Join Date: Jan 2003
Location: ~/
Status:
Offline
|
|
Here's the challenge - I periodically receive PDF files from a single specific email address. I'm trying to figure out a way to have Apple's Mail application automatically print the attachments when the email arrives.
Now, I'm not bad at Automator programming, but AppleScript is a bit beyond my level (last time I had to program anything similar, it was in AppleSoft FP BASIC!). I can write a script to tell an Automator "application" to run (one whole line - tell application "my_automator_action" to run) at least.
I've gone through all the built-in Automator actions combined with some others I've found online, but I've never been able to find a way to do it.
Any AppleScript geniuses have any thoughts??
|
|
|
|
|
|
|
|
|
Addicted to MacNN
Join Date: May 2001
Location: Cupertino, CA
Status:
Offline
|
|
Okay, I'm not an AppleScript expert, so I couldn't get printing from my Mail rule to work and had to use both a script and an Automator workflow, but here goes.
This solution requires you to have a folder named Mail Attachments on your desktop. You can change this by editing the first line of the AppleScript. First, create your rule in Mail and use this script as its action:
Code:
property destinationFolder : (path to desktop as Unicode text) & "Mail Attachments:"
using terms from application "Mail"
on perform mail action with messages theMessages for rule theRule
tell application "Mail"
repeat with eachMessage in theMessages
repeat with thisAttachment in eachMessage's mail attachments
if (MIME type of thisAttachment) is equal to "application/pdf" then
set thisFile to destinationFolder & name of thisAttachment
save thisAttachment in thisFile
end if
end repeat
end repeat
end tell
end perform mail action with messages
end using terms from
Next, create an Automator workflow with these actions: Print Finder Items and then Move to Trash. Go to File > Save as Plug-in and save it as a Folder Action on the Mail Attachments folder, making sure to enable folder actions.
Now your rule should execute when messages are received from the address you specify, any PDFs received in messages caught by the rule will be saved into the Mail Attachments folder, the folder action will be triggered and the PDFs will get printed and then deleted.
|
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: Jan 2007
Status:
Offline
|
|
okay.... this is cool
but what if i want it to print any attachment? rahter than just a pdf file?
and am i able to just copy & paste or do i need to edit anything?
thanks in advance
|
|
|
|
|
|
|
|
|
Addicted to MacNN
Join Date: May 2001
Location: Cupertino, CA
Status:
Offline
|
|
You can remove these lines entirely:
Code:
if (MIME type of thisAttachment) is equal to "application/pdf" then
....
end if
That'll print all attachments. Or you can replace "application/pdf" with another MIME type if you want to print only a different type of file. Or you can change it to check against a list of types by doing this:
Code:
if (MIME type of thisAttachment) is in {"application/pdf", ... } then
Replacing the ellipses with a list of more MIME types you want to be printed. You can probably lookup MIME types for other file formats on Google.
|
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: Feb 2007
Status:
Offline
|
|
So I tried copying and pasting the code into AppleScript but when I try to save it I get an error message. I don't really know anything about Scripts. Could you explain to me how to make this script to print any attachments from my emails?? And also is there a way to make the script run automatically at a certain time of day, say 9 AM. So when I get to work my attachments are already printed out... Oh and if it helps my attachments are excel files...
Thanks
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|