使用 applescript 获取邮件主题

发布于 2024-12-10 02:30:26 字数 1133 浏览 0 评论 0原文

我正在使用 Mail applescript 模板编写脚本(文件 > 从模板新建 > 邮件 > 邮件规则 Action.scptd),但模板中的示例似乎不起作用

using terms from application "Mail"
      on perform mail action with messages these_messages for rule this_rule
                tell application "Mail"
                          set the message_count to the count of these_messages
                          repeat with i from 1 to the message_count
                                    set this_message to item i of these_messages
                                    try
                                              set this_subject to (subject of this_message) as Unicode text
                                              if this_subject is "" then error
                                    on error
                                              set this_subject to "NO SUBJECT"
                                    end try
                            say this_subject
                          end repeat
                end tell
      end perform mail action with messages
end using terms from

它甚至说“没有主题”如果邮件有主题。我使用的是 OS X 10.7.2 和 Mail 5.1。有什么建议吗?

I'm writing a script using the Mail applescript template (File > New from template > Mail > Mail Rule Action.scptd) but it doesn't seem like the examples in the template are working

using terms from application "Mail"
      on perform mail action with messages these_messages for rule this_rule
                tell application "Mail"
                          set the message_count to the count of these_messages
                          repeat with i from 1 to the message_count
                                    set this_message to item i of these_messages
                                    try
                                              set this_subject to (subject of this_message) as Unicode text
                                              if this_subject is "" then error
                                    on error
                                              set this_subject to "NO SUBJECT"
                                    end try
                            say this_subject
                          end repeat
                end tell
      end perform mail action with messages
end using terms from

It says "no subject" even if the message has a subject. I'm using OS X 10.7.2 and Mail 5.1. Any suggestions?

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

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

发布评论

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

评论(2

皇甫轩 2024-12-17 02:30:27

我在 10.8.2 (Mail 6.2) 下工作,是否有帮助?这是我正在使用的代码:

using terms from application "Mail"
    on perform mail action with messages theMessages for rule theRule
        tell application "Mail"
            repeat with eachMessage in theMessages
                try
                    set this_subject to subject of eachMessage
                    if this_subject is "" then error
                on error
                    set this_subject to "No subject."
                end try
                say this_subject
            end repeat
        end tell
    end perform mail action with messages
end using terms from

希望有帮助吗?

I have this working under 10.8.2 (Mail 6.2) if it helps at all? This is the code I'm using:

using terms from application "Mail"
    on perform mail action with messages theMessages for rule theRule
        tell application "Mail"
            repeat with eachMessage in theMessages
                try
                    set this_subject to subject of eachMessage
                    if this_subject is "" then error
                on error
                    set this_subject to "No subject."
                end try
                say this_subject
            end repeat
        end tell
    end perform mail action with messages
end using terms from

Hope that helps?

天赋异禀 2024-12-17 02:30:27

尝试在将 this_subject 设置为(this_message 的主题)作为 Unicode 文本下添加delay 3。邮件可能没有时间在转到下一个命令之前处理邮件以获取主题行。

如果这有效,您可能不需要 3 秒钟。您可以尝试减少延迟时间。请注意,您可以使用小数,如 1.8 中所示。

Try adding delay 3 under set this_subject to (subject of this_message) as Unicode text. It may be that Mail doesn't have time to process the message to get the subject line before moving to the next command.

If this works, you may not need 3 seconds. You can experiment with decreasing the delay time. Note that you can use decimals, as in 1.8.

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