• 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
A script to read the next message in Mail, read or unread
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

A script to read the next message in Mail, read or unread


  • Subject: A script to read the next message in Mail, read or unread
  • From: Tommy Bollman <email@hidden>
  • Date: Tue, 18 May 2010 06:32:53 +0200

I't would have been cool if you liked it; there are some more in the coming.
The script and the inRSSFeed() is copyright © Tommy Bollman 2010 but put in the public domain
for general use and loot..
If you tinker with it, then write that you did so before you pass it on.

(*
Purpose: lets you opens the next message to the currently selected one, that is the message below
the selected one if the message window currently displays a mailbox and not an RSS feed.

If you are in threaded mode before running this script it will turn threaded mode off.

This is meant for view messages in a particular mailbox or a set of messages gathered toghether, 
and not by thread, as that is easy enough to do by means of existing keyboard commands ¬
(arrow down/space and cmd-o).

To be honest I haven't figured out how to expand a thread in Mail, but I feel no use for that in 
the context of this script.

Selections:
It is soo easy to open every message in a selection with with cmd-o after having
selected the messages. This script consider's a selection as messages already opened and skips
those, should there be any.

*)

global thisId, selID
tell application "Mail"
try
set inRSS to my inRSSFeed()
if inRSS is true then -- Nothing to do.
beep 2
return
end if
tell front message viewer
set visibleMsgs to {}
-- it may happen that no messages are selected.
set visMsgs to count of visible messages
if visMsgs ≠ 0 then -- Nothing to do
set visibleMsgs to visible messages
else
beep 2
return
end if


set selMsgs to count of selected messages
if selMsgs ≠ 0 then
set selectedMsgs to selected messages


set selID to id of (item -1 of selectedMsgs)
set msgClass to class of (item -1 of selectedMsgs)
-- change to "item 1" If you want to start with the first selected message.
set lastID to id of item -1 of visibleMsgs
-- change this to selected messages if you want to keep within the selected messages.
set selMsgCount to count of selectedMsgs
set visMsgCount to count of visibleMsgs


if selMsgCount = visMsgCount or selID = lastID then -- was on last message, nothing to do.
beep 2
return
else
(*
Must loop within visible messages until we find the msg with same id.
if there is any messages left ( index < count - 1 then we go to next message. *)
set msgIndex to 1
repeat with aMsg in visibleMsgs
set thisId to (id of aMsg as integer)
if thisId = selID then exit repeat
set msgIndex to msgIndex + 1
end repeat
if msgIndex < visMsgCount then
set theClass to class of (item (msgIndex + 1) in visibleMsgs) as text
if theClass is "Application" then
display alert "Please turn off: \"Organize by Thread\""
beep 2
return
end if
set selected messages to {item (msgIndex + 1) in visibleMsgs}
open selected messages
else
beep 2
return
end if
end if
else
set nextMessage to {}
if visMsgs = 1 then
set nextMessage to visibleMsgs
else
-- set tMg to first message of visibleMsgs
set nextMessage to {item 1 of visibleMsgs}
end if


set selected messages to nextMessage
open selected messages
end if


end tell
on error e number n
beep 2
end try
end tell


on inRSSFeed()
set inFeed to false
tell application "Mail"
set wnlist to its every window as list
repeat with aWn in wnlist
copy name of aWn to thNm
considering case
if thNm contains "RSS" then
copy index of aWn to wnIdx
copy index of front message viewer to mgVwIdx
if wnIdx is mgVwIdx then
set inFeed to true
exit repeat
end if
end if
end considering
end repeat
end tell
return inFeed
end inRSSFeed



Regards





Tommy Bollman



--------------------

No act of kindness, no matter how small, is ever wasted.
-- Aesop

 _______________________________________________
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

  • Follow-Ups:
    • Re: A script to read the next message in Mail, read or unread
      • From: Tommy Bollman <email@hidden>
  • Prev by Date: Re: Getting Info from the Finder
  • Next by Date: Fwd: Getting Info from the Finder
  • Previous by thread: Re: AppleScript-Users Digest, Vol 7, Issue 257
  • Next by thread: Re: A script to read the next message in Mail, read or unread
  • Index(es):
    • Date
    • Thread