Hello. I’ve been trying to figure this one out on my own, but really can’t find anything that addresses the problem.
My workflow on this starts with an e-mail that triggers the rule that launches this script. The problem i’m having is that only the portions of this script that directly relate to Mail.app (v 3.5 under OS 10.5.6) are processed. the rest just dies…
in my testing the only way that the non-mail.app portions will run is if the mail portion errors out when saving the attachment (like… if an identically named file exists in the save location and i don’t tell it how to handle that problem)… which renders everything down the line useless.
i’ve tried nesting the non-mail stuff inside the mail code and tried using "using terms from application ‘XXX’ " to no avail.
i’m trying to avoid using a folder action to launch the rest of the script, but if all else fails then maybe it’ll have to do.
any insight would be spectacular.
using terms from application "Mail"
on perform mail action with messages theMessages for rule theRule
set destinationFolder to ((path to desktop) as Unicode text)
tell application "Mail"
repeat with This_Message in theMessages
repeat with oneAttachment in mail attachments of This_Message
set {name:theName, MIME type:mimeType} to oneAttachment
if theName ends with ".csv" then
save oneAttachment in (destinationFolder as Unicode text) & theName
end if
end repeat
end repeat
end tell
end perform mail action with messages
end using terms from
set openpath to ((path to desktop) & "test.csv" as Unicode text)
tell application "BBEdit"
activate
open {file openpath}
end tell