使用 applescript 获取邮件主题
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在 10.8.2 (Mail 6.2) 下工作,是否有帮助?这是我正在使用的代码:
希望有帮助吗?
I have this working under 10.8.2 (Mail 6.2) if it helps at all? This is the code I'm using:
Hope that helps?
尝试在
将 this_subject 设置为(this_message 的主题)作为 Unicode 文本
下添加delay 3
。邮件可能没有时间在转到下一个命令之前处理邮件以获取主题行。如果这有效,您可能不需要 3 秒钟。您可以尝试减少延迟时间。请注意,您可以使用小数,如 1.8 中所示。
Try adding
delay 3
underset 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.