Re: Getting Next and Previous Messages in Apple Mail
Re: Getting Next and Previous Messages in Apple Mail
- Subject: Re: Getting Next and Previous Messages in Apple Mail
- From: Adam Tow <email@hidden>
- Date: Wed, 25 May 2005 18:59:17 -0700
Everyone:
I figured out a roundabout way of selecting the next message in Mail.
It's a bit of a hack; what I do is send an up or down keystroke event
to the Mail application before I process the selected messages.
=========
tell application "Mail"
activate
set msgs to selection
set vViewer to front message viewer
if index of vViewer is 1 then
tell vViewer
activate
set visibleMsgs to visible messages
set lastVisible to last item of visibleMsgs
set lastMsg to last item in msgs
-- If the last selected message is the last message in
the list, select the previous message
if message id of lastMsg = message id of lastVisible then
set keycode to 126
else
set keycode to 125
end if
tell application "System Events" to keystroke (key code
keycode)
end tell
end if
-- Continue processing
end
=========
-adam
Everyone:
Is there a way to select the next or previous message in Apple Mail
based on the current sort in a message viewer? It would seem that
Mail defaults to date received descending when using the before/after
modifier. For instance:
tell application "Mail"
set vViewer to front message viewer
set index of vViewer to 1
tell vViewer
set visibleMsgs to visible messages of vViewer
set selectedMsgs to selected messages
set lastItem to last item in selectedMsgs
set beforeItem to message before lastItem
return subject of beforeItem
end tell
end tell
It doesn't matter if the message viewer is sorted by date ascending,
subject, from, etc., the script still returns the next/previous
message based on date descending. I can't seem to use:
set beforeItem to message before lastItem in visibleMsgs
set beforeItem to message before lastItem in selectedMsgs
Of course, I could iterate through the every message in the list, but
that takes a long time when you have lots of messages in a mailbox.
Does anyone know of an alternate way to get the next/previous message
in the message viewer based on the current sort parameters?
Thanks!
-adam
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden