问题
It seems, that the method of saving a mail attachment with applescript is broken under Lion. Assume, 'theAttachment' is already the right object containing the e.g. attached jpg, here is what I've done:
set strPath to (path to pictures folder) as string
save theAttachment in strPath -- leads to the error: "„Mail“ got an error: error in AppleEvent-Routine." number -10000
save theAttachment in strPath as "test" -- leads to \"test\" can't convert into typ constant" number -1700 from "test" to constant
set fileName to strFileName as alias
save theAttachment in strPath as fileName -- error "The file „Foto-121121.jpg“ wasn't found." number -43 from "Foto-121121.jpg"
And also it's not possible to create the file via touch:
set thefullpath to POSIX path of strPath & fileName
do shell script "touch \"" & thefullpath & "\"" -- error "The file „Foto-121121.jpg“ wasn't found." number -43 from "Foto-121121.jpg"
Several sources found by Google said, that the method mentioned above works well under Snow Leopard, but doesn't in Lion. Is there any workaround ?
Remark: I've translated the error messages from German here, but the error numbers are still the same.
回答1:
How about Automator? The Get Attachments from Mail Messages
action would work.
来源:https://stackoverflow.com/questions/7722381/save-mail-attachment-from-applescript-in-lion