通过Applescript将Apple Mail附件附加到Apple Notes

问题描述

我正在研究将Apple Mail邮件复制到Apple Notes中的脚本。到目前为止一切顺利,但是我很难将附件放入新创建的笔记中。这是在macOS Catalina 10.15.7上。

昨天我花了半天时间寻找解决方案,但是它们都不起作用。 当我执行make new attachment语句时,对于电子邮件中找到的每个附件,都会收到以下错误Notes got an error: Can’t make show id "x-coredata://32E6D9EF-97F3-424F-B151-DD166A00E0AB/ICNote/p9725" into type specifier.每个附件的UID都是相同的。

我尝试了各种路径变化(作为POSIX文件,文本或原样),但是都给出了相同的错误

这个简单的代码示例已经在第2行给出了错误

set theNote to make new note at folder NotesFolder with properties {body:theBody}
make new attachment at theNote with data theFileName

其中FileName是电子邮件附件的完整路径,临时保存在桌面上的文件夹中,以便Applescript和Notes可以访问它。 由于错误消息中的UID对于找到的每个附件都是相同的,因此也可能是theNote不好。

任何想法这有什么问题吗?还是Notes遇到问题(我读过Catalina中的Notes似乎有Applescripting错误

目前,我很茫然,因此非常感谢您的帮助。

解决方法

您是否可以创建附件,例如指定文件夹,帐户和注释ID:

tell application "Notes"
    activate
    set theNote to make new note in folder "AB" of account "On My Mac" with properties {name:"3038665"}
    tell theNote
        make new attachment at end of attachments with data "/Users/xyz/Desktop/ab_download/test.jpg"
    end tell
end tell