I have a certain script-generated email that arrives with a single HTML file attached. I am trying to get the computer to print this file for me. I am not sure I am considering the problem properly or if there are better options, so I’m here asking for advice. Here is my current code:
-- bastardized from... -- Paul Berkowitz's Save Attachments 2004 tell application "Microsoft Entourage" set attachFolderPath to (((path to MUD) as Unicode text) & "Saved Attachments:") set theMsg to item 1 of (get current messages) set msgAttachments to attachments of theMsg repeat with i from (count msgAttachments) to 1 by -1 set theAttachment to item i of msgAttachments set attachName to name of theAttachment set fileSpec to (attachFolderPath & attachName) end repeat end tell tell application "Safari" open fileSpec delay 1 --give Safari time to load graphics print document 1 without print dialog close document 1 end tell
I don’t particularly like the delay between open and print, but if I don’t have it the page can print without graphics having loaded. The delay also gives the user (potentially me) time to interfere with Safari and the script, and if things are particularly slow the graphics may not fully load before printing happens.
I also don’t really like Safari popping up the new window and then closing it, it is distracting to the user should they be using the computer when this script fires off.
Is there an option other than Safari I could use? Is there a way to print the HTML file without anything opening and closing on-screen? Anything else I’m not considering?