• 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: Cannot open "On My Mac" mailboxes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cannot open "On My Mac" mailboxes


  • Subject: Re: Cannot open "On My Mac" mailboxes
  • From: Christopher Stone <email@hidden>
  • Date: Sat, 05 May 2012 19:48:50 -0500

Hey Tom,

On May 05, 2012, at 08:37, Tom Lyon wrote:
But seriously, lack of documentation is killing me.

:)

I'm afraid you're going to feel that for a while.  People who have experience with other programming languages tend to feel the most pain.  Hang in there and keep asking questions.

BUT tell us what you want to accomplish in more general terms, so we can help you get there faster.  Banging your head against the wall only gets you dain brammage.

You're going to chafe under Applescript's limitations.  I suggest you get started now with with either the Satimage.osax, or Shane's ASObjC Runner, or both.  At the very least you want the regex.

It functions properly for a mailbox in the top hierarchy of "On My Mac" but generates an error ('Error: Mail got an error: Can't get mailbox "some mailbox" Error Number: -1728') for any mailboxes that are in a lower hierarchy.

Be sure to always use a try..on error statement (p. 207 of the Applescript Language Guide), so you get a glimmer of error help.  I changed the display dialog statement below one to include a 'copy' (to clipboard) item.

You can also uncomment the 'clipboard' line to copy the error message to the clipboard directly and comment out the other stuff when you're debugging.

I changed your script slightly, and it works for me up to a 3rd level mailbox.

Let me know if you still have problems.

You're on Lion?

By the way I really like the MailHub and Mail Act-On plugins for message filing and other jobs, but both of those are commercial.

--
Best Regards,
Chris

------------------------------------------------------------------------------------------------
try

  

  tell application "Mail"

    

    set selectedMessages to selection

    

    if selectedMessages = {} then error "Oops!  No messages are selected."

    

    set mailboxList to mailboxes whose ¬
      name is not "Drafts" and ¬
      name is not "Notes" and ¬
      name is not "Deleted Messages" and ¬
      name is not "Outbox"

    

    set mailboxNameList to name of mailboxes whose ¬
      name is not "Drafts" and ¬
      name is not "Notes" and ¬
      name is not "Deleted Messages" and ¬
      name is not "Outbox"

    

    # The 'tell me to' is only to maintain focus in the Applescript Editor while editing.
    # tell me to 
    set selectedMailboxName to ¬
      choose from list mailboxNameList default items "123net" with prompt "Choose Mailbox:" with title "On My Mac Mailbox List:" with empty selection allowed

    

    if selectedMailboxName is not false and selectedMailboxName is not {} then
      set selectedMailboxName to item 1 of selectedMailboxName
      repeat with i from 1 to length of mailboxNameList
        if item i of mailboxNameList = selectedMailboxName then exit repeat
      end repeat
      set selectedMailbox to item i of mailboxList

      

      repeat with theMessage in selectedMessages
        move theMessage to selectedMailbox
      end repeat

      

    end if

    

  end tell

  

on error eMsg number eNum
  set {c, s} to {return, "------------------------------------------"}
  set e to s & c & "Error: " & eMsg & c & s & c & "Error Number: " & eNum & c & s
  beep
  # set the clipboard to e
  set dDlg to display dialog e buttons {"Cancel", "Copy", "OK"} default button "OK"
  if button returned of dDlg = "Copy" then
    set the clipboard to e
  end if
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: 
 >Cannot open "On My Mac" mailboxes (From: Tom Lyon <email@hidden>)
 >Re: Cannot open "On My Mac" mailboxes (From: Christopher Stone <email@hidden>)
 >Re: Cannot open "On My Mac" mailboxes (From: Tom Lyon <email@hidden>)
 >Re: Cannot open "On My Mac" mailboxes (From: Christopher Stone <email@hidden>)
 >Re: Cannot open "On My Mac" mailboxes (From: Tom Lyon <email@hidden>)
 >Re: Cannot open "On My Mac" mailboxes (From: Christopher Stone <email@hidden>)
 >Re: Cannot open "On My Mac" mailboxes (From: Tom Lyon <email@hidden>)

  • Prev by Date: Re: Gui script for Preview
  • Next by Date: Re: Cannot open "On My Mac" mailboxes
  • Previous by thread: Re: Cannot open "On My Mac" mailboxes
  • Next by thread: Re: Cannot open "On My Mac" mailboxes
  • Index(es):
    • Date
    • Thread