• 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
An Error in Mail
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

An Error in Mail


  • Subject: An Error in Mail
  • From: Luther Fuller <email@hidden>
  • Date: Tue, 27 Sep 2011 10:56:40 -0500

I was trying to get some info from Mail with this script ...

tell application "Mail"
activate
set frontViewer to (some message viewer whose index is 1)
set msgList to (selected messages of frontViewer)
set msgCount to (count items of msgList)
if msgCount = 0 then return
end tell

but, I kept getting an error telling me that msgList was undefined.
There were no selected messages, so msgList should be defined as {}.
I finally tried this ...

tell application "Mail"
activate
set frontViewer to (some message viewer whose index is 1)
set msgList to (selected messages of frontViewer)
try
set msgCount to (count items of msgList)
on error
return
end try
end tell

and it worked correctly.
It seems that Mail does NOT return an empty list if there is no selection. Instead,
selected messages of frontViewer incorrectly returns NOTHING if there are no selected messages.

 _______________________________________________
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

  • Follow-Ups:
    • Re: An Error in Mail
      • From: Michelle Steiner <email@hidden>
  • Prev by Date: Re: Getting full file paths on clipboard with AS
  • Next by Date: Re: An Error in Mail
  • Previous by thread: Re: Getting full file paths on clipboard with AS
  • Next by thread: Re: An Error in Mail
  • Index(es):
    • Date
    • Thread