I have the following applescript working under Lion, but it returns this Error: -10000. Mail got an error: AppleEvent handler failed.
error under Yosemite.
try
tell application "Mail"
set theViewer to front message viewer
set theMsg to messages of theViewer
set msgList to {}
repeat with thisMsg in theMsg
if read status of thisMsg is false and flagged status of thisMsg is false then
set the end of msgList to thisMsg
end if
end repeat
if msgList is {} then
display dialog "There are no read messages in this mailbox."
else
tell theViewer to set properties to {visible messages:msgList}
end if
end tell
on error the errMsg number the errNmb
if the errNmb is not -128 then
set the errTxt to "Error: " & the errNmb & ". " & the errMsg
display dialog the errTxt buttons {"Cancel"} default button 1
else
error number -128
end if
end try
Any help would be appreciated.
Best Answer
From comments…
As it would appear that many people across the net are struggling & failing to get
set properties to {visible messages:msgList}
to work at all, it might be simpler in the long run to just pop up a count of unread/unflagged messages & optionally sort by flagged then unread for easy discovery in the Mail window.I added in a 'sort by date or flags/unread' option in the dialog, too