Microsoft outlook我们有一个脚本可以使用或应用程序发送电子邮件Apple mail。它将从系统首选项(也可能是用户输入)动态加载默认电子邮件,并使用它来决定使用哪个邮件客户端。
所以代码如下:
if (mailClientStr contains "outlook")
tell application id "com.microsoft.outlook"
-- <<< there will be error if there is no outlook installed
-- <<< even else branch will be run.
...
end tell
else
tell application id "com.apple.mail"
...
end tell
end if
在没有安装 Outlook 的机器上,mailClientStr将是“com.apple.mail”,但此脚本无法运行osascript
它抱怨Can’t get application id "com.microsoft.outlook"即使第一个分支也不会被执行。我的理解是osascript在加载和编译这个脚本时(在运行它之前)需要访问 Outlook 苹果脚本界面。
我可以将outlook相关的代码分离成一个单独的脚本,但是因为要传递的数据很多,会比较复杂,所以我不想要这个变通方法。那么苹果脚本语言方面有什么解决方案吗?