Re: Mail and AppleScript frustration (newbie)
Re: Mail and AppleScript frustration (newbie)
- Subject: Re: Mail and AppleScript frustration (newbie)
- From: has <email@hidden>
- Date: Fri, 11 Jan 2008 15:58:39 +0000
On 11 Jan 2008, at 11:45, Aurélien Hugelé wrote:
I would like to access some specific messages in Mail.app.
I've looked at tons of example and suceeded to access *selected*
messages, but not to a specific message by its "id"
[...]
tell application "Mail"
set theMessage to message 399989 of mailbox "INBOX" of account
"Support OD" of application "Mail"
end tell
To refer to a message element by id, the above should read:
tell application "Mail"
set theMessage to message id 399989 of mailbox "INBOX" of account
"Support OD"
end tell
(Emphasis on 'id' in 'message id 399989'.)
The problem is that Mail already defines a 'message id' keyword of its
own (it's a property of the 'message' class), so when you try to
compile the above you get a compiler error due to the conflicting
terminology.
Luca's already provided an AppleScript-based workaround for this
problem. However, if you're working in ObjC, you might consider
bypassing AppleScript altogether and just sending all your Apple
events directly. Right now the best solution for this is objc-appscript:
http://appscript.sourceforge.net/objc-appscript.html
Officially it's still alpha-ware, but it's already pretty complete and
reasonably robust, and should work on anything from Panther onwards.
As an added bonus, it's also a lot less susceptible to terminology
conflicts, allowing you to specify 'message' elements by id without
any problems, e.g.:
MLApplication *mail = [[MLApplication alloc] initWithBundleID:
@"com.apple.mail"];
MLReference *messageRef = [[[[[[mail accounts] byName: @"Support OD"]
mailboxes] byName: @"INBOX"]
messages] byID: [NSNumber
numberWithInt: 399989]];
If you've any questions about it, just drop us a mail.
HTH
has
--
http://appscript.sourceforge.net
http://rb-appscript.rubyforge.org
_______________________________________________
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