• 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: Filter threads for Mail.app (contribution)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Filter threads for Mail.app (contribution)


  • Subject: Re: Filter threads for Mail.app (contribution)
  • From: Matt Petrowsky <email@hidden>
  • Date: Mon, 29 Dec 2003 09:41:02 -0800

Updated my script to work with Panther's Mail.app.

Name the script something like "Filter Thread___cmd-shift-T"
and then reading threads by subject line will be much more enjoyable in Mail.app.

(You may need to remove hard returns added by wrapping caused in email clients)

-- By Matt Petrowsky
-- email@hidden

-- This script is designed to narrow the visible messages to only those found within the same thread
-- Only works with Panther's Mail.app

on realThread(theString)
if characters 1 thru 4 of theString as string is equal to "Re: " then
set theSubject to characters 5 through -1 of theString as string
else
theString
end if
end realThread


tell application "Mail"
tell message viewer 1 -- target the frontmost window
set selectedMailboxes to selected mailboxes
if (count of selectedMailboxes) = 1 then -- make sure only one mailbox is selected so you can get the subject line
set selectedMailbox to item 1 of selectedMailboxes

-- NOTE! For some reason mailboxes might have hidden messages. This makes it hard to know
-- when you have a filtered list of messages or not. This may need to be adjusted or fixed.
-- Don't have the time to fix it right now. :(

if (count of (visible messages)) < (count of (messages of selectedMailbox)) - 100 then
set visible messages to {}
return
end if
else
display dialog "This function only works within one mailbox!" & return & return & "Please select just one mailbox" buttons {"OK"} default button "OK" with icon stop
return
end if
-------------------------------------------
set selectedMsgs to selected messages
if (count of selectedMsgs) = 1 then -- make sure only one message is selected so you can get the subject line
set keyMsg to item 1 of selectedMsgs
set theSubject to my realThread(subject of item 1 of selectedMsgs)
else
display dialog "You must have a single message selected" buttons {"OK"} default button "OK" with icon note
return
end if
-- Now capture all the messages with the same subject
set mainMessage to every message of selectedMailbox whose subject is theSubject
set theThread to every message of selectedMailbox whose subject is ("Re: " & theSubject)
set theThread to mainMessage & theThread
set visible messages to theThread
end tell
end tell



On Apr 15, 2003, at 11:12 PM, Matt Petrowsky wrote:

Here's a nice contribution for those of you using Mail.app. Filter messages by thread topic - subject line.

If you use QuicKeys or iKey (formerly Youpi Key) then this script really rocks for reading list archives in Mail.app! (doesn't work for digest lists)

This script when put into your macro program will allow you to filter out a specific thread (ala the Outlook grouping feature on Windows) Of course, sorting by subject groups full threads but this is much cooler.

The script is a toggle script so I assigned mine to Cmd-Down Arrow in QuicKeys. The cool thing is that you can go back to reading the full list archive when sorted in chronological order.

Enjoy!

Matt Petrowsky

-- TOGGLE THREAD SCRIPT
-- 2003 by Matt Petrowsky
-- Thanks to cricket for the tips on the focused messages feature!

-- This routine strips off the "Re: " if part of the selected message
----------------------------------------------------------------------- -------------------
on realThread(theString)
if characters 1 thru 4 of theString as string is equal to "Re: " then
set theSubject to characters 5 through -1 of theString as string
else
theString
end if
end realThread

-- This is the main script. This is a toggle script so you can call it to switch between
-- focused messages and the selected mailbox
tell application "Mail"
tell message viewer 1 -- target the frontmost viewer window
if (count of focused messages) = 0 then -- focus on the selected message
set selectedMailboxes to selected mailboxes
set selectedMailbox to item 1 of selectedMailboxes
set selectedMessages to selected messages
set selectedMessage to item 1 of selectedMessages
set theSubject to my realThread(subject of selectedMessage)
set mainMessage to every message of selectedMailbox whose subject is theSubject
set everyMessage to every message of selectedMailbox whose subject is ("Re: " & theSubject)
set everyMessage to everyMessage & mainMessage
set focused messages to everyMessage
else
set focused messages to {} -- clear the focused messages
end if
end tell
end tell
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: mail.app save all attachments
  • Next by Date: Display Dialog bug in Xcode?
  • Previous by thread: Re: mail.app save all attachments
  • Next by thread: Display Dialog bug in Xcode?
  • Index(es):
    • Date
    • Thread