• 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: Mail navigation script
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mail navigation script


  • Subject: Re: Mail navigation script
  • From: Christopher Stone <email@hidden>
  • Date: Fri, 02 Nov 2012 05:09:11 -0500

On Nov 02, 2012, at 02:21, Dave C <email@hidden> wrote:
I am trying to develop (well, actually modify) a script to provide navigation in an Apple Mail mailbox. 

When a message window is open, Mail does not provide a means to move to the next message without doing this little dance:
______________________________________________________________________

Hey Dave,

Yes.  This is a horrible, glaring deficiency in Mail.  Every sensible mail client has the ability to go-to the next message, the previous message, the next unread message, or the previous unread message.

Unfortunately given threading and sorting I don't see a way to reliably do it with Applescript.

I fooled with the attached methods without reliable success with Mountain Lion's Mail (6.2).  You can see if either method bears fruit with Snow Leopard.

--
Best Regards,
Chris

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

try

  

  tell application "Mail"

    # close front window

    

    tell (some message viewer whose index is 1)
      set _mailbox to item 1 of (get selected mailboxes)
      set _msg to item 1 of (get selected messages)

      

      set _date to date sent of _msg
      set _id to id of _msg
      set mList to {(last message of _mailbox whose date sent > _date)}

      

      set selected messages to mList

      

    end tell

    

  end tell

  

on error e number n
  set e to e & return & return & "Num: " & n
  tell me to set dDlg to display dialog e with title "ERROR!" buttons {"Cancel", "Copy", "OK"} default button "OK"
  if button returned of dDlg = "Copy" then set the clipboard to e
end try

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

On Mountain Lion selList fails to reliably set the selected messages, and the 2nd set selected messages to selList throws an error.

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

try

  

  tell application "Mail"

    

    tell (some message viewer whose index is 1)
      set mbox to item 1 of (get selected mailboxes)
      set msg to item 1 of (get selected messages)

      

      set _flag to false

      

      repeat with i in (reverse of (get messages of mbox))

        

        set _temp to (contents of i)

        

        if _flag = true then
          set nextMsg to _temp
          exit repeat
        end if

        

        if _temp = msg then
          set _flag to true
        end if

        

      end repeat

      

      set selList to {nextMsg}
      selList
      set selected messages to selList
      selList
      open nextMsg
      selList
      set selected messages to selList ## ERRORS HERE WITH EMPTY LIST — BUG MAYBE ##
      selList

      

    end tell

    

  end tell

  

on error e number n
  set e to e & return & return & "Num: " & n
  tell me to set dDlg to display dialog e with title "ERROR!" buttons {"Cancel", "Copy", "OK"} default button "OK"
  if button returned of dDlg = "Copy" then set the clipboard to e
end try

-------------------------------------------------------------------------------------------
 _______________________________________________
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: 
 >Mail navigation script (From: Dave C <email@hidden>)

  • Prev by Date: Re: Saving to array list
  • Next by Date: Re: wrong result when trying to get Selection from finder window
  • Previous by thread: Mail navigation script
  • Next by thread: Re: Mail navigation script
  • Index(es):
    • Date
    • Thread