Hello, Im using this mail rule, or I was under Tiger, now I can’t get it to work on Leopard, only if I use the rule man, i’ve added it as a rule for all incomming messages, but nothing works, can somebody tell me why
(*
Save mail as PDF.
*)
using terms from application "Mail"
on perform mail action with messages theMessages for rule theRule
repeat with eachMessage in theMessages
tell application "Mail"
tell eachMessage
set theSender to (extract name from sender)
set thedate to date received
set theContents to content as text
set theSubject to subject as text
set theId to id as Unicode text
end tell
set theAccount to name of account of mailbox of eachMessage
end tell
set thedate to short date string of thedate
set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to {"."}
set thedate to text items of thedate
set AppleScript's text item delimiters to oldDelims
set thedate to text items of thedate as text
set mailPath to make_folder(path to documents folder, "Mails")
set AccountFolder to make_folder(mailPath, theAccount)
set IDFolder to make_folder(AccountFolder, theId)
set TempFile to (IDFolder as Unicode text) & theSender & "_" & theSubject & ".txt"
try
set theTextFile to open for access TempFile with write permission
write "From: " & theSender & return & "Date: " & thedate & return & "Subject: " & theSubject & return & return & theContents to theTextFile
close access theTextFile
end try
set the_posix_file to POSIX path of TempFile
set terminalCommand to ""
set convertCommand to "/System/Library/Printers/Libraries/./convert "
set newFileName to the_posix_file & ".pdf"
set terminalCommand to convertCommand & "-f " & "\"" & the_posix_file & "\"" & " -o " & "\"" & newFileName & "\"" & " -j \"application/pdf\""
do shell script terminalCommand
tell application "Mail"
repeat with theAttachment in (get eachMessage's mail attachments)
set theFileName to (IDFolder as Unicode text) & "#" & theId & space & theAttachment's name
try
save theAttachment in theFileName
on error errNum
end try
end repeat
end tell
end repeat
end perform mail action with messages
end using terms from
on make_folder(fPath, fName)
try
return ((fPath as string) & fName) as alias
on error
tell application "Finder" to set newfolder to make new folder at fPath with properties {name:fName}
end try
return newfolder as alias
end make_folder
/mkh