• 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: problem with a mail.app script
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: problem with a mail.app script


  • Subject: Re: problem with a mail.app script
  • From: Kim Holburn <email@hidden>
  • Date: Tue, 13 Apr 2004 01:04:34 +1000

On 2004 Apr 12, , at 5:53 AM, BJ Terry wrote:

On Apr 10, 2004, at 4:16 PM, Kim Holburn wrote:

I am trying to write a mail.app rule script that opens a new window when I get mail moved to a mailbox.

None of these do anything. I get a new message viewer window but the script can never select a mailbox. Anyone have any hints?


--
Kim Holburn

On my computer, if I run the following script:

tell application "Mail"
set theWindow to make new message viewer with properties {visible:true}
set selected mailboxes of theWindow to {mailbox "myMailbox"}
end tell

It won't select the mailbox. But if I add a delay of 1 second before setting the mailbox, like so:

tell application "Mail"
set theWindow to make new message viewer with properties {visible:true}
delay 1
set selected mailboxes of theWindow to {mailbox "cal_acacia_spring04"}
end tell

it works fine. The window isn't really ready to receive a new selection when it first opens, you just have to give it a second.

Excellent, thank you, that works fine.

I have another question for the list.

I want to open a message viewer with a selected mailbox only if there is no other message viewer with that mailbox selected.

I wrote a little loop (inside a tell application "Mail"):

repeat with mv in message viewers
if visible of mv then
repeat with mb in selected mailboxes of mv
if mb is equal to mbox then --
set madeWindow to 1
exit repeat
end if
end repeat
if madeWindow = 1 then
exit repeat
end if
end if
end repeat


My problem is comparing mailboxes doesn't seem to work. Should it? There doesn't seem any kind of ID property of mailboxes which would make this a simple compare.

If I add some statements:

repeat with mv in message viewers
if visible of mv then
repeat with mb in selected mailboxes of mv
set nmb to ""
try
set nmb to name of mb
end try
set dt to "nmb:(" & nmb & ") nmbox:(" & theMboxName & ")"
display dialog dt

if mb is equal to mbox then
set madeWindow to 1
exit repeat
end if
end repeat
if madeWindow = 1 then
exit repeat
end if
end if
end repeat

I only ever get "nmb:() nmbox:(fred)". What am I doing wrong?

--
Kim Holburn
IT Manager, Canberra Research Laboratory
National Information and Communication Technology Australia
Ph: +61 2 61258620 M: +61 0417820641
Email: email@hidden - PGP Public Key on request

Life is complex - It has real and imaginary parts.
Andrea Leistra (rec.arts.sf.written.Robert-jordan)
_______________________________________________
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.


  • Follow-Ups:
    • Re: problem with a mail.app script
      • From: BJ Terry <email@hidden>
References: 
 >problem with a mail.app script (From: Kim Holburn <email@hidden>)
 >Re: problem with a mail.app script (From: BJ Terry <email@hidden>)

  • Prev by Date: Moving to Panther
  • Next by Date: Re: Moving to Panther
  • Previous by thread: Re: problem with a mail.app script
  • Next by thread: Re: problem with a mail.app script
  • Index(es):
    • Date
    • Thread