I’m writing an applescript to burst emails in digest format and create separate emails for each message (for use with Mail.app). Here is what I have so far:
using terms from application "Mail"
(*on perform mail action with messages theMessages for rule theRule*)
on perform mail action with messages incomingMessages
tell application "Mail"
(*repeat with msg in theMessages*)
set messageText to source of theMessage
do shell script "formail +1 -ds " & messageText & " >/Users/mike/Desktop/testoutput"
(*end repeat*)
end tell
end perform mail action with messages
end using terms from
I am running the script from within script editor and from the scripts menu in Mail.app. the script appears to run and I expect to have a file called testoutput on my desktop when it is run but I don’t. I should at least get an empty file if the do shell script line is executed, even if the message text is not properly passed in. I don’t get any error messages or anything so I’m not sure what happening (or not). Any ideas about what I’m doing wrong?
cheers
Mike
using terms from application "Mail"
(*on perform mail action with messages theMessages for rule theRule*)
on perform mail action with messages incomingMessages
tell application "Mail"
repeat with msg in incomingMessages
set messageText to source of msg
do shell script "formail +1 -ds " & messageText & " >/Users/mike/Desktop/testoutput"
end repeat
end tell
end perform mail action with messages
end using terms from
Yeah, there are a few quirks to remember here. When you want to open a file for access, you set another variable to open that file:
set inFile to "Macintosh HD:Users:mike:Desktop:in"
set write_This to open for access file inFile with write permission
write "im here" to write_This
close access write_This
hmmm im trying to incorperate this into my autoprint script, but i cant even get this to work…seems like the shell is being tricky on my end? may i ask what version of OS X you guys are running? i’m desperately wanting this to work out.
well my idea was to use this script to move mail to a text file and then use poisx as a path to print the mail…if u dont remember, i was the one trying to automatically print a mail message that mets a rule specified in mail.app
so if i cant even get this script working, my question is. is there something wrong with my do shell or mail.app?
Well, I have been playing with this today, and searched around a lot, and it seems that (in my opinion) that the scripting of a printer is pretty darn difficult. The [lpr] seems to only work with a PDF file, not TXT files. The [print] command in the Standard AppleScript Suite doesn’t do anything (except freeze up the script), and after you write a TXT file, TextEdit puts up a dialog box every time you tell it to print. It is amazing.
I will continue to look around for this; I have some UNIX books at home that may help, but I don’t know when (or if) I can figure this out.
hrm well if it might help, what about printing the txt to a pdf or something that lpr understands and then, printing that documents and then erasing it…i know its a round about way and ill toy with it some, but it might work.
Right, roundabout, but certainly should work. I know that there are a few threads here on creating PDF files, but I have never really pursued that. Have a look around, and see what you can come up with. I will continue to look into my UNIX texts for other possible solutions.
Working on it. I posted a thread in the Unix forum at Apple, since I believe that is where the big problem lies. I have been trying off and on all week to get a .txt file to print from the command line, and have not yet succeeded.
the shell command “lpr test2.txt” just printed the text file to my usb connected canon inkjet printer. This dosen’t work for you? I’m using Mac os X tiger.
-Mike
i have no problem printing from shell, its when im tryin to print a mail message or anything via apple script. it doesnt like it, maybe its because its a network printer vs a usb printer. and yes im also using tiger.