Re: mail.app: can't get selection
Re: mail.app: can't get selection
- Subject: Re: mail.app: can't get selection
- From: Paul Berkowitz <email@hidden>
- Date: Sat, 04 Jun 2005 18:36:56 -0700
- Thread-topic: mail.app: can't get selection
Title: Re: mail.app: can't get selection
On 6/4/05 6:20 PM, "tim" <email@hidden> wrote:
Hi,
I've been trying to write a script to rewrite the source of an email in mail.app
I keep getting stumped at just trying to get the message I have selected
1. I f i say "tell application return selection" i get a list containing (apparently) a meesage reference
but i can't say "get item 1 of selection" : this returns the error can't make reference.
Also can't access any property of any item of what should be a list of selected messages.
Any clues on this?
Secondly, this script just seems wierd: how can p not be defined when it has been iterated over?
tell application "Mail"
repeat with anitem in selection --two messages selected
set p to anitem
end repeat
return p
--applescript error the variable p is not defined
Try
(get selection)
That one is pretty common, for 'selection' property of an application, in many apps (including Entourage, which you know well).
And if you want to force an error anywhere in any of the weirdo iApps, you have to
get someVariable -- get p
immediately after defining the variable. Otherwise it won't error until you next try to use the variable – it doesn't error when you first define it.
This works:
tell application "Mail"
repeat with anitem in (get selection)
set p to anitem
end repeat
return p
end tell
but gets you that weird reference format
--> item 3 of {
message id 5719 of mailbox "INBOX" of account "email@hidden",
message id 5720 of mailbox "INBOX" of account "email@hidden",
message id 5721 of mailbox "INBOX" of account "email@hidden"
}
So this is better:
tell application "Mail"
repeat with anitem in (get selection)
set p to anitem
end repeat
return contents of p
end tell
--> message id 5721 of mailbox "INBOX" of account "email@hidden"
--
Paul Berkowitz
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden