using terms from application "Mail" on perform mail action with messages theMessages log "Welcome to perform mail action" set attachmentsFolder to path to documents folder rule type string log "attachmentsFolder is " & attachmentsFolder --& "Attachments:" rule type rich text set attachmentsFolder to attachmentsFolder & "Attachments:" log "attachmentsFolder now is " & attachmentsFolder tell application "Mail" set selectedMessages to theMessages try repeat with theMessage in selectedMessages log "theMessage is " & theMessage repeat with theAttachment in theMessage's mail attachments set originalName to name of theAttachment log "originalName is " & originalName set savePath to attachmentsFolder & originalName log "savePath is " & savePath save theAttachment in file savePath end repeat end repeat on error errMsg number n set commonError to "on error " & " errMsg is " & errMsg & " number is " & n log commonError display dialog commonError giving up after 15 return 3 ----- > bye bye end try end tell end perform mail action with messages end using terms from (* Uncomment when you want to debug this script in the Script Editor. *) (* *) on run log "runnning..." tell application "Mail" try set theSelectedMessages to selection log "class of theSelectedMessages is " & class of theSelectedMessages log "count of theSelectedMessages is " & (count of theSelectedMessages) on error errMsg number n display dialog "Silly, you need to select a message in Mail." & return & "on error the errMsg is " & errMsg & " number is " & n giving up after 8 return end try -- not used, don't know how to pass to perform ... set theRule to {name:"dummyRule"} tell me to perform mail action with messages theSelectedMessages -- for theRule end tell -- app "Mail" end run (**) (**)