• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Next unread message in Mail.app
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Next unread message in Mail.app


  • Subject: Re: Next unread message in Mail.app
  • From: Jim Krenz <email@hidden>
  • Date: Mon, 25 May 2009 15:48:51 -0700

Hi Luther,

Thanks for the suggestions. I ended up discarding my AppleScript, as I found one that was close in functionality from Andreas Amann. With my suggestions, he rewrote the script, and it works well. He is considering releasing it with his Mail Scripts.

I'm attaching it here, in case anyone is following this thread, and would find it useful. If you love it (as I do), consider sending your thanks to Andreas.

Attachment: Open Next Unread Message.scpt
Description: Binary data


Jim

On May 20, 2009, at 6:45 PM, Luther Fuller wrote:

On May 20, 2009, at 8:07 PM, Jim Krenz wrote:

I am trying to create a script that will move to the next mailbox with unread messages, and select the first unread message. I haven't been successful (I'm still a AppleScript beginner). Here is what I have thus far. Any suggestions are welcome.

tell application "Mail" to try
tell message viewer 1 to set selected messages to {first message of beginning of (get mailbox whose unread count > 0) whose read status is false}
activate
on error
beep
end try

Here's something you might want to experiment with (10.5.7) ...

tell application "Mail"
activate
set frontViewer to (message viewer 1)
set allMailboxes to mailboxes as list -- does not need open message viewer
repeat with mbox in allMailboxes
try
if (count messages of mbox) > 0 then
set selected mailboxes of frontViewer to {mbox}
set msg to first message of frontViewer
set selected messages of frontViewer to {msg} -- does NOT always hilite a message
display dialog (subject of msg) as text --*****************diagnostic
delay 1
end if
on error errText number errNr
"Error = " & errNr & return & errText
display dialog the result default button 2
end try
end repeat
end tell
tell application "Finder" to beep

I was surprised to find that 'set selected messages ...' does not always select something and I still cannot figure out why. I try to avoid "one liners", they often create errors. Or make errors hard to find.

Even if the message is not selected, 'msg' seems to be valid.
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Re: Excel Save as text question (From: Stan Cleveland <email@hidden>)
 >Next unread message in Mail.app (From: Jim Krenz <email@hidden>)
 >Re: Next unread message in Mail.app (From: Luther Fuller <email@hidden>)

  • Prev by Date: Re: Swap foreground and background windows
  • Next by Date: Re: changing the "open with application" value for a file
  • Previous by thread: Re: Next unread message in Mail.app
  • Next by thread: Re: Excel Save as text question
  • Index(es):
    • Date
    • Thread