Corrected description to be true in the matter that you have to turn of threaded mode yourself.
Added showing the preview pane when in an RSS feed, removing the preview pane when viewing a regular
account.
(*
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.
You have to turn off threaded mode yourself.
if we are in an rss-feed when inovoked we set the preview window to true
else if the preview window is on we set it to false, that is: if the current
mailbox doesn't contain an RSS feed.
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.
-- this is more for a "read selected - script" which I will make real soon.
--
It is so easy to open every message if you have several messages selected, but there could
be times in a large mailbox that you would like to constraint the opening of messages within
the selection. That should be farily easy to implement.
or the next message which isn't selected from your mailbox.
=> This may be kind of contradictory.
Purpose:
Lets you open interesting messages in a thread.
The message viewer can be in either threeview, in a set of filtered
messages from multiple mailboxes or from just the current mailbox (not RSS feed).
It does nothing fancy like letting you choose another mailbox or something to get messages from
There should be some options for this maybe, but that is in the next round.
if we are in a mailbox, it would be logical to go to the next message in the list.
Installed in the mail scripts folder and added a a shortkey to it
it will open the next message in the current mailbox leaving to you to close
the messages not interesting.
*)
global thisId, selID
tell application "Mail"
try
set inRSS to my inRSSFeed()
if inRSS is true then -- Nothing to do
tell front message viewer
activate
set preview pane is visible to true
end tell
beep 2
return
end if
tell front message viewer
if preview pane is visible then
set preview pane is visible to false
end if
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