根据网络上的各种代码片段,我正在尝试实现一个简单的AppleScript,以将邮件附件保存到文件夹中。
set thePath to ((path to home folder as text) & "Documents")
tell application "Mail"
set selectedMessages to selection
set theMessage to item 1 of selectedMessages
set theAttachments to theMessage's mail attachments
repeat with theAttachment in theAttachments
set originalName to name of theAttachment
set savePath to (thePath & ":" & originalName)
display dialog ("Saving attachment to " & savePath)
save theAttachment in savePath
end repeat
end tell
以下是运行脚本时对话框报告的内容,其中在Mail中选择了一条已附加图像的消息:
将附件保存到Macintosh HD:用户:billtubbs:文档:20180415_103233.jpg
这是我收到的错误消息:
error "Mail got an error: To view or change permissions, select the item in the Finder and choose File > Get Info." number -10000
它在线上升起
save theAttachment in savePath