简体   繁体   English

AppleScript无法读取Mail.app的消息

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

I've had a script that used to work perfectly to check if I've received an email with a certain subject (below): 我有一个脚本可以很好地检查我是否收到了带有特定主题的电子邮件(如下):

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

Now AppleScript refuses to read emails' subjects. 现在,AppleScript拒绝阅读电子邮件的主题。 Any ideas why? 有什么想法吗? I'm assuming there's been an update that's broken it but I can't find any information on that. 我假设有一个破坏它的更新,但是我找不到任何信息。

尝试

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

I have a 10.7.4 computer and get an error when there is no message with those properties are found. 我有一台10.7.4的计算机,当找不到包含这些属性的消息时出现错误。 If there is an unread message containing that subject, the script (the one that says "first message of inbox") works fine. 如果存在包含该主题的未读消息,则脚本(写有“收件箱中的第一条消息”的脚本)可以正常工作。

This seems to work for me, I first had to select the first message and then I could get the subject: 这似乎对我有用,我首先必须选择第一个消息,然后才能理解该主题:

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