• 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
OS X Mail.app scripting
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

OS X Mail.app scripting


  • Subject: OS X Mail.app scripting
  • From: "J. B. Stewart" <email@hidden>
  • Date: Fri, 16 Nov 2001 17:08:10 -0500

There seems to be another slight bug in the Mail.app for OS X.

The following script checks each of my mailboxes (14) used to separate emails by various email lists. It also filters out the INBOX, Outbox and Trash (amongst others). The results are then used to export the emails to a database. While setting this up I made and deleted a mailbox and this is probably the cause of the problem.

The script generates this error when it tries to access the non-existant last mailbox - Mail got an error: NSReceiverEvaluationScriptError: 4

(* Script Start *)
property mbFilter : {"INBOX", "Outbox", "Trash"}
tell application "Mail"
set x to count mailboxes of account 1
repeat with y from 1 to x
set mb to mailbox y of account 1
log y -- for troubleshooting
if ((mailbox name) of mb) is not in mbFilter then
count messages of mb
end if
end repeat
end tell
(* Script End *)

Script Debugger outputs the following Apple Event log

<snip>
get mailbox 12 of account 1
--> mailbox 12 of account 1
(*12*)
get mailbox name of mailbox 12 of account 1
--> "SD-Talk"
count every message of mailbox 12 of account 1
--> 0
get mailbox 13 of account 1
--> mailbox 14 of account 1
(*13*)
<snip>

The access of mailbox 12 is correct as mailbox 12 is returned however asking for mailbox 13 returns mailbox 14. It appears as though Mail.app is not correctly re-indexing mailboxes when one has been deleted. This carries through for all remaining mailboxes. The dictionary for Mail allows for access by index but not by ID yet it appears to treat indexes as IDs assigned at creation of the mailbox.

I would appreciate some independent checking and verification of this prior to filing a bug report.

From email@hidden Fri Nov 16 20:00:03 2001
Path: forum.apple.com!newsxfer3.itd.umich.edu!news.maxwell.syr.edu!newsfeed.direct.ca!look.ca!newsfeed1.earthlink.net!newsfeed.earthlink.net!newsmaster1.prod.itd.earthlink.net!newsread1.prod.itd.earthlink.net.POSTED!not-for-mail
Message-ID: <email@hidden>

  • Follow-Ups:
    • OS X Mail.app scripting "check mail"
      • From: Joseph Weaks <email@hidden>
  • Prev by Date: Re: Modify Data Fork
  • Next by Date: Re: Hacking unfinished programs
  • Previous by thread: Re: Strange raw code problem
  • Next by thread: OS X Mail.app scripting "check mail"
  • Index(es):
    • Date
    • Thread