Skip navigation
This discussion is archived

AppleScript Automation

903 Views 0 Replies Latest reply: Jul 23, 2010 2:06 PM by AppleScript Automation RSS
AppleScript Automation Calculating status...
Currently Being Moderated
Jul 23, 2010 2:06 PM
I have a desire to use applescript and CUPS to solve a data conversion problem. The input to this process will be

single EML files, sometimes numbering in the 10s of 1000s. These would reside in a directory named INPUT.

I would use Automator to accept files from this folder at the time the workflow was initiated. The workflow would

contain two steps. First would be to select the location of INPUT. Second would be to run a piece of applescript.

This applescript would use Mail to open each EML file and print to CUPS. Within the CUPS configuration, I can

specify the destination of all things printed to the CUPS printer. Mail is the only application that will open EML

files on Mac out of the box.

I found this script that uses Mail to open a message, then uses AppleScript to grab specific parts of the message,

like headers and content, then writes these to a temporary text file, then prints the text file to the default

printer (set in the interface to be CUPS).

This script may work the way it is. I would not know. The minute I drop a Custom AppleScript step into my workflow

and drop this script in the workflow does not accept input and asks me to debug line by line. I’m unable to do

this. I don’t know how to write applescript and I’m not a programmer.


AppleScript

on run {input, parameters}

tell application “Mail”
set selectedMessages to |SelectedMessages| of input
repeat with eachMessage in selectedMessages
set theEmail to (headers of eachMessage as text) & return & return ¬
& (content of eachMessage as text)
set theTextFile to open for access “:MailText” with write permission
set theTempFile to (“:MailText” as alias)
write theEmail to theTextFile
close access theTextFile
do shell script “lpr /MailText”
tell application “Finder”
delete theTempFile
end tell
end repeat
end tell

return input
end run

Thanks

Actions

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.