尝试保存邮件附件时AppleScript文件权限错误


0

根据网络上的各种代码片段,我正在尝试实现一个简单的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

Answers:


1

我不确定权限问题,但是当我在你引用的行中使用“file”时,我没有收到任何错误。

save theAttachment in file savePath

其中savePath是文件的别名。如果别名已存在(例如,作为您复制到该位置的模板),则通过将附件保存到该位置,您应该没有权限问题。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.