简体   繁体   English

AppleScript和Mail.app:检查特定帐户中的新消息

[英]AppleScript and Mail.app: checking for new messages in specific account

I want to include the number of new messages from a specific mail account in my zsh prompt, but I can only get mail to return the total number of new mails. 我想在zsh提示符中包括来自特定邮件帐户的新邮件数量,但是我只能获取邮件以返回新邮件的总数。

set output_string to "" 将output_string设置为“”
tell application "Mail" 告诉应用程序“邮件”
set Unread_Count to unread count of inbox 将Unread_Count设置为收件箱的未读计数
if Unread_Count is 0 then 如果Unread_Count为0,则
set output_string to "0" 将output_string设置为“ 0”
else 其他
set output_string to ("" & (get Unread_Count)) 将output_string设置为(“”&(获取Unread_Count))
end if 万一
end tell 结束告诉
return Unread_Count 返回Unread_Count

I've tried several other approaches like: 我尝试了其他几种方法,例如:

set Unread_Count to unread count of account "Gmail" 将Unread_Count设置为帐户“ Gmail”的未读计数

but without any luck. 但没有运气。

I would appreciate your help! 多谢您的协助!
thanks! 谢谢!

Try: 尝试:

tell application "Mail" to set undreadMessages to messages of mailbox "INBOX" of account "my account name" whose read status = false

EDIT for Marcus Rickert 编辑马库斯·里克特(Marcus Rickert)

tell application "Mail" to set Unread_Count to count (messages of mailbox "INBOX" of account "my account name" whose read status = false)

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

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