如何使用 applescript 获取默认邮件客户端?

发布于 2024-09-28 14:23:45 字数 40 浏览 3 评论 0原文

谁能告诉我,如何使用 applescript 获得默认邮件客户端?

Can anyone please tell me, how do I get the default mail client using applescript?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

此岸叶落 2024-10-05 14:23:45

我在此处找到了这段代码的一部分,并在 Snow Leopard (10.6.4) 上运行它,这对我有用。

on run
    set mailClient to getDefaultMailClient()   -- store application id
    tell application id mailClient to activate -- tell mail client to do something
end run

-- Grab id of default mail client
on getDefaultMailClient()
    set prefPath to (path to preferences as text) & "com.apple.LaunchServices.plist"
    tell application "System Events"
        try
            value of property list item "LSHandlerRoleAll" of ¬
                (first property list item of property list item "LSHandlers" of ¬
                 property list file prefPath whose value of property list items ¬
                 contains "mailto")
            on error
                "com.apple.mail"
        end try
    end tell
end getDefaultMailClient

I found part of this code here, ran it on Snow Leopard (10.6.4), and it worked for me.

on run
    set mailClient to getDefaultMailClient()   -- store application id
    tell application id mailClient to activate -- tell mail client to do something
end run

-- Grab id of default mail client
on getDefaultMailClient()
    set prefPath to (path to preferences as text) & "com.apple.LaunchServices.plist"
    tell application "System Events"
        try
            value of property list item "LSHandlerRoleAll" of ¬
                (first property list item of property list item "LSHandlers" of ¬
                 property list file prefPath whose value of property list items ¬
                 contains "mailto")
            on error
                "com.apple.mail"
        end try
    end tell
end getDefaultMailClient
初心未许 2024-10-05 14:23:45

另一种选择:VERSIONER_PERL_PREFER_32_BIT=1 perl -MMac::InternetConfig -le 'print +(GetICHelper "mailto")[1]'

Another option: VERSIONER_PERL_PREFER_32_BIT=1 perl -MMac::InternetConfig -le 'print +(GetICHelper "mailto")[1]'

ゞ记忆︶ㄣ 2024-10-05 14:23:45

macscripter-forum 中对此主题进行了讨论
在那里您还可以找到一些关于如何测试默认邮件客户端的代码示例

there has been a discussion on this toppic in the macscripter-forum
there you find also some code examples on how test for the default mail-client

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文