|
|
#21 |
|
Prospect
Join Date: Jul 2003
Posts: 10
|
My rule is something along the lines of if subject contains "print" then print.
and lpr seems to be active (as in working) through the console. My code is as follows: Code:
on perform_mail_action(info)
tell application "Mail"
set selectedMessages to |SelectedMessages| of info
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
end perform_mail_action
|
|
|
|
|
|
#22 |
|
MVP
Join Date: Jan 2002
Location: Boston, MA
Posts: 1,489
|
further empirical testing:
comment out the lines Code:
tell application "Finder"
delete theTempFile
end tell
__________________
:: 3.4GHz Core i7 iMac 4GB RAM :: Black MacBook SR :: 10.7.2 :: iPhone 4 / iOS 5 :: Last edited by rusto; 08-08-2003 at 06:15 PM. |
|
|
|
|
|
#23 |
|
Prospect
Join Date: Jul 2003
Posts: 10
|
I'll try that this weekend... thanks and I'll keep you posted
)
|
|
|
|
|
|
#24 |
|
Site Admin
Join Date: Jan 2002
Location: Montreal
Posts: 32,473
|
use full paths in 'do shell script'
Read this Apple article about 'do shell script':
http://developer.apple.com/technotes/tn2002/tn2065.html One of the most important things it tells you is that you should use full paths for any executables or files referred to in the script. Thus you should use /usr/bin/lpr instead of just lpr. The section "Dealing with Files" might also be useful - the 'POSIX path' and 'POSIX file' constructions are useful when going back & forth between AppleScript and UNIX shell scripts. |
|
|
|
|
|
#25 |
|
MVP
Join Date: Jan 2002
Location: Boston, MA
Posts: 1,489
|
Good stuff to keep in mind when debugging, Hayne. Thanks!
__________________
:: 3.4GHz Core i7 iMac 4GB RAM :: Black MacBook SR :: 10.7.2 :: iPhone 4 / iOS 5 :: |
|
|
|
|
|
#26 |
|
Prospect
Join Date: Jul 2003
Posts: 10
|
Still no Luck
Hmm... I posted the code exactly as stated under "success," but it still will not work. I also tried using full path names to lpr and I tried using my full printer name.
I also tried to comment out the lines that delete the temp file. When I ran the script again I couldn't find the temp file. Possible reasons why this is not working: 1. I am using my airport base as a print station. 2. I am not using the default account that came on this ibook. I created a new one and then delete that one. I gave this account "addminister" privileges, so I assume my current account to be no different to the original account. Thank again, Will |
|
|
|
|
|
#27 |
|
Prospect
Join Date: Jul 2003
Posts: 10
|
ping
ping
|
|
|
|
|
|
#28 |
|
Major Leaguer
Join Date: Oct 2003
Location: UK
Posts: 306
|
Wonderfull, just what I needed, needed some tweaking on my machine as I didn't get headers, I've reduced this info down to the sender, time, subject & content.
Code:
using terms from application "Mail" on perform_mail_action(info) tell application "Mail" set selectedMessages to |SelectedMessages| of info repeat with eachMessage in selectedMessages set theSender1 to the sender of eachMessage set theSender to "From: " & theSender1 set theDate to the date received of eachMessage set dateReceived to "Received: " & theDate set theSubject1 to subject of eachMessage set theSubject to "Subject: " & theSubject1 set theContents to the content of eachMessage set theEmail to theSender & return & dateReceived & return & theSubject & return & return & theContents 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 end perform_mail_action end using terms from |
|
|
|
|
|
#29 |
|
MVP
Join Date: Jan 2002
Location: Boston, MA
Posts: 1,489
|
Thanks for the update, I love to see a great old thread revived!
__________________
:: 3.4GHz Core i7 iMac 4GB RAM :: Black MacBook SR :: 10.7.2 :: iPhone 4 / iOS 5 :: |
|
|
|
|
|
#30 |
|
Prospect
Join Date: Jan 2005
Posts: 7
|
Thanks a buch for the scripts folks, bun none of the scripts work, the first one prints but only "?" is printed. The other one "the above" doest even print.
Anymore great ideas would be apprecited.
|
|
|
|
|
|
#31 |
|
Major Leaguer
Join Date: Oct 2003
Location: UK
Posts: 306
|
I don't actually use it myself, one of my clients wanted it, it did work correctly when posted, I'll check it out to see what's going wrong.
|
|
|
|
|
|
#32 |
|
Major Leaguer
Join Date: Oct 2003
Location: UK
Posts: 306
|
Still works for me, I would test lpr from your terminal to make sure that command operates, write a text file using textedit, (covert to plain text Format>Make plain text), save it in your home folder as test.txt, then type: lpr test.txt
in the terminal and hit return. If that does not function try: /usr/bin/lpr test.txt Make sure your default printer is set to an available printer before running any of these commands. Last edited by darndog; 01-23-2005 at 02:21 PM. |
|
|
|
|
|
#33 |
|
Registered User
Join Date: Feb 2005
Posts: 1
|
Gpg
I'm having an issue with the print script and GPG. I've got GPG working in Mail, but when I use a auto print script I get the unencrypted source. Does anyone have script to decrypt and print?
|
|
|
|
![]() |
|
|