繁体   English   中英

AppleScript无法读取Mail.app的消息

[英]AppleScript can't read Mail.app's messages

我有一个脚本可以很好地检查我是否收到了带有特定主题的电子邮件(如下):

tell application "Mail"
check for new mail
repeat until (background activity count) = 0
    delay 0.5
end repeat
try
    return subject of (first message whose read status is false and subject contains "New newsletter ordered by")
end try
end tell

现在,AppleScript拒绝阅读电子邮件的主题。 有什么想法吗? 我假设有一个破坏它的更新,但是我找不到任何信息。

尝试

return subject of (first message of inbox whose read status is false and subject contains "New newsletter ordered by")

我有一台10.7.4的计算机,当找不到包含这些属性的消息时出现错误。 如果存在包含该主题的未读消息,则脚本(写有“收件箱中的第一条消息”的脚本)可以正常工作。

这似乎对我有用,我首先必须选择第一个消息,然后才能理解该主题:

tell application "Mail"
   set theInbox to inbox
   set theMessage to first message of theInbox whose read status is false
   tell front message viewer to set selected messages to {theMessage}
   set theMessages to (get selection)
   repeat with theMessage in theMessages
       get subject of theMessage as string
   end repeat
end tell

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM