使用 applescript 在 Outlook 中创建带附件的消息

Create a message with attachment in Outlook using applescript

我正在尝试在 Microsoft Outlook 版本 15.6 中打开一封新邮件 window 并填充包含附件的字段。这是我的动作脚本代码:

tell application "Microsoft Outlook"
    set newMessage to make new outgoing message with properties {subject:"Hooray for automation"}
    make new recipient at newMessage with properties {email address:{name:"Jim Shank", address:"jim.shank@example.com"}}
make new attachment at the end of newMessage with properties {file:"/tmp/Invoice INV2 - Paul.pdf"}
    open newMessage
end tell

(此消息来自 this stack overflow question)。

但是,我收到此错误:256:398:执行错误:Microsoft Outlook 收到错误:保存更改的记录时出错 属性。 (-2700)

是否可以在最新版本的 Outlook 中使用 actionscript 打开新邮件?

这是一个 applescript;也许会有帮助?

tell application "Microsoft Outlook.app"
activate
set theFile to "Macintosh HD:Users:Shared:sp.zip"
set newMessage to make new «class outm» with properties {«class subj»:"Outlook is back"}
make new «class rcpt» at newMessage with properties {«class emad»:{name:"Mark", «class radd»:"blah@blah.com"}}
tell newMessage
    set theAttachment to make new «class cAtc» with properties {file:theFile}
    «event mailsend»
end tell
end tell

我找到了解决方案:我需要在脚本的前面添加以下行:

set x to "/Users/foo/file" as POSIX file

详情请见本页: