Re: Re1: Mail scripting : How to select…
Re: Re1: Mail scripting : How to select…
- Subject: Re: Re1: Mail scripting : How to select…
- From: Axel Luttgens <email@hidden>
- Date: Fri, 9 May 2008 23:50:34 +0200
Le 9 mai 08 à 17:40, awaw a écrit :
Thanks,
I re-send it because Re2 appears but not the first one (Re)
I add also a new problem at the end.
__________
set selected mailboxes of message viewers to {mailbox "Junk" of
account "Gérard"}
With "Junk", "Trash" or "Sent" only : no problem!
I have tried to known these names but I never succeed.
tell application "Mail"
set x to mailboxes of inbox
set y to count of x
display alert y
set i to 1
repeat y times
set z to item i of x as string
display alert z
set i to i + 1
end repeat
end tell
==> Erreur d'AppleScript "Il est impossible de rendre «class mbxp»
"INBOX" of «class mact» "Gérard" of application "Mail" en type
string."
That's because of a wrong implicit asumption: a mailbox may be coerced
into a string.
But clearly, Mail doesn't support such coercions.
So, let's just make use of Mail'dictionary and replace
set z to item i of x as string
by
set z to name of item i of x
And one should get "INBOX" for each mailboxes of inbox.
(but I'm seemingly just rephrasing what you wrote hereafter)
tell application "Mail"
set x to mailboxes of inbox
set y to count of x
display alert y
set i to 1
repeat y times
set z to name of item i of x as string
display alert z
set i to i + 1
end repeat
end tell
==> INBOX
INBOX (y times)
As a side note: the name of a mailbox is already a string, so the "as
string" part isn't needed here.
But no names
But yes! "INBOX" is the name of each of these mailboxes.
They are distinguisable by the fact that they belong to differing
accounts: mailbox "INBOX" of account "Gérard", maibox "INBOX" of
account "Jules", and so on.
Is it possible to obtain them otherwise?
I guess you are in fact thinking about the "custommailbox/submailbox/
subsubmailbox" naming scheme.
But that seems to only apply to user-defined mailboxes, as a kind of
shortcut.
The general rule for naming is: mailbox "subsubmailbox" of mailbox
"submailbox" of mailbox "custommailbox" (with in this case the top-
level piece being a mailbox, not an account).
By asking for
name of mailbox "custommailbox/submailbox/subsubmailbox"
you'll anyway get "subsubmailbox", not "custommailbox/submailbox/
subsubmailbox".
____________
The last "gravel in my shoes".
Trash mailbox and Junk mailbox have a special "sub-folder" : "sur
mon Mac"
I don't know the "real" name for using it in Applescript (to select
it).
In the case of the Trash for example, this should be
mailbox "Deleted Messages"
which contains every messages deleted from local mailboxes.
You may find it by asking for "every mailboxes" (i.e. the mailboxes
that are elements of Mail).
The problem is that there are several layers to be taken in account.
Application level: when creating an account, that account potentially
may have several mailboxes, according to the kind of account (POP,
IMAP...); by creating a local (i.e. custom, "sur mon Mac") mailbox,
one is organizing local storage of messages according to the user's
fantasy.
GUI level: for example, it may appear sensible to group all deleted
messages under a same "visual container", such as the Trash, even if
the mailboxes are possibly very different (deleted messages on an IMAP
server may be on the server and never be stored locally).
AppleScript object model level: the model must allow to access all
mailboxes, without losing the specifics of ecah mailbox considered
individually; hence the account-related mailboxes, managed by the
application itself (and accessed through properties of the
application), and the user-defined mailboxes (accessed as elements of
the application).
In the hope I managed to write something legible...
Axel
_______________________________________________
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