Applescript将文件附加到邮件消息。在OSX 10.4到10.6中工作的将不会在10.8中工作

Applescript将文件附加到邮件消息。在OSX 10.4到10.6中工作的将不会在10.8中工作,applescript,osx-mountain-lion,email-attachments,Applescript,Osx Mountain Lion,Email Attachments,在10.8中,我的Applescript(在运行10.4到10.6时开发)读取逗号分隔的文本文件,使用这些值创建新邮件,然后使用NSstring路径名将xx.pdf文件附加到该文件,仍然发送电子邮件,但不包括附件。通过研究这个问题,我了解到10.8安全增强功能已经“沙盒”了Mail应用程序和applescript应用程序,因此路径名不再是指向该文件的有效、可传递的链接。我发现了几个声称可以解决此问题的示例,声称NSstring“file name:”必须替换为NSURL格式的文件名,但代码看起来

在10.8中,我的Applescript(在运行10.4到10.6时开发)读取逗号分隔的文本文件,使用这些值创建新邮件,然后使用NSstring路径名将xx.pdf文件附加到该文件,仍然发送电子邮件,但不包括附件。通过研究这个问题,我了解到10.8安全增强功能已经“沙盒”了Mail应用程序和applescript应用程序,因此路径名不再是指向该文件的有效、可传递的链接。我发现了几个声称可以解决此问题的示例,声称NSstring“file name:”必须替换为NSURL格式的文件名,但代码看起来不像applescript,并且不会在applescript编辑器中编译。您是否有将文件附加到新的、由applescript生成的电子邮件消息的applescript示例?我几天来一直试图解决这个问题,但没有成功。我甚至打电话给苹果支持热线,但他们说苹果不再支持Applescript相关问题

我从文本文件传入的变量名为“theAttachment1”。我正在努力实现的目标是:

“在最后一段之后创建属性为{file name:theAttachment1}的新附件


同样,它在10.4到10.6中运行良好,但在10.8中不起作用。

这在10.8中对我有效

   set theAttachment1 to POSIX file "/Users/USERNAME/Desktop/Desktop--IMAGE/scooter-6.jpg"

tell application "Mail"
    set newMessage to make new outgoing message with properties {subject:"subject", content:"the_content" & return & return}
    tell newMessage

        set visible to false
        set sender to "myaddress@btinternet.com"
        make new to recipient at end of to recipients with properties {address:"someAddress@btinternet.com"}
        make new attachment with properties {file name:theAttachment1} at after the last paragraph

        (* change save to send to send*)
        save --<<<<---------------- change save to send to send
        (* change save to send to send*)
    end tell
end tell
将附件1设置为POSIX文件“/Users/USERNAME/Desktop/Desktop--IMAGE/scooter-6.jpg”
告诉应用程序“邮件”
设置newMessage以生成具有属性{subject:“subject”,content:“the_content”&return&return}的新传出消息
告诉新消息
将可见设置为false
将发件人设置为“myaddress@btinternet.com"
在结尾处向收件人添加新的收件人,并向具有属性{地址:}的收件人添加新的收件人someAddress@btinternet.com"}
在最后一段之后创建属性为{file name:theAttachment1}的新附件
(*将保存更改为发送更改为发送*)

保存--你可以发布你的完整脚本和一个文本文件的示例以及文件路径。我想你也在谈论字符串和文件url,而不是NSString…这是如何解决的???。如果这是我的答案,你应该接受它。如果是另一种方式,请解释它,让其他人受益。