save mail attachment from applescript in Lion

我们两清 提交于 2019-12-20 04:45:14

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!