• 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: ScriptingBridge to access Mail Messages?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ScriptingBridge to access Mail Messages?


  • Subject: Re: ScriptingBridge to access Mail Messages?
  • From: has <email@hidden>
  • Date: Sat, 31 May 2008 23:15:20 +0100


Thomas Wickl wrote:

first of all, I´m new to Cocoa and I need some Informations about the
possibilities in Cocoa to plan a new Project of mine.
I want to access all Messages of my Mail.app Account. So, there is no
API for Mail.app but I´ve read something about the ScriptingBridge and
found that SendMail Example. But is it possible to get a list of all E-
Mails in Mail with this Scriptingbridge?

SB can perform a subset of what's possible with AppleScript, so if you can do it in AppleScript then in theory you should be able to do it in SB as both AS and SB build on the same Apple Event Manager API. However, SB's design is such that some functionality is obfuscated almost to the point of incomprehensibility (e.g. the by-test reference form, aka 'whose clauses'), whilst some other things just plain break because the SB designers tried to be clever and make it work the way they think Apple event IPC should work instead of the way it actually does. (Alas, SB's two-steps-forward-one-step-back approach is pretty much par for the course for AppleScript's development over the years.)


Depending on exactly what it is you want to do, you might find it quicker and easier to read Mail's mailbox files directly. e.g. See:

	http://lists.apple.com/archives/Cocoa-dev/2008/May/msg02912.html

I can't tell you if that's an officially sanctioned approach though, so caveat emptor and do your own research first.


Where can I find information what is possible with Mail.app and the
Scripting Bridge? Is there a description or referenz about all
scripting possibilities in Mail.app?


With a few rare exceptions (e.g. Adobe, Microsoft apps), Mac applications' scripting interfaces are notoriously underdocumented. You can start with the Mail's built in AppleScript dictionary, which provides a basic description of the API itself, although doesn't provide sufficient information to know how to use it. Beyond that, it's a case of learning how application scripting works in general (hint: it helps to realise that it's RPC+queries; if you mistake it for OOP as most folks do, beyond a certain point it'll confuse the heck out of you), and looking at existing code examples (99% of which are written in AppleScript, so I'm afraid you'll need to learn the language a bit even if you don't use it yourself), asking for assistance with specific problems (again, the AppleScript forums are your best bet for this), and good old trial and error experimentation (again, a scripting language will be quicker for this).

Matt Neuburg's 'AppleScript: The Definitive Guide' is probably a good place to start; the current (second) edition doesn't cover Leopard- specific developments, but given that neither the language nor the basic concepts behind application scripting don't evolve much from release to release, this isn't a big deal. (Also, Matt isn't shy about discussing its various flaws, which is both helpful and reassuring.) And here's a link to the AppleScript-users mailing list where a lot of the experienced Mail scripters can be found:

	http://lists.apple.com/mailman/listinfo/applescript-users

Also, obligatory reference to my own contributions: the Python, Ruby and ObjC appscript bridges (essentially Scripting Bridge done right), ASDictionary (which exports nicely formatted application dictionaries in AppleScript and appscript syntax) and ASTranslate (which you can use to translate AppleScript commands to the equivalent appscript syntax - very handy when learning the latter). See my sig for links.

HTH

has
--
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.net

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: Leak when animating Core Animation Superlayer
  • Next by Date: Re: Possible Bug in NSFileManager -moveItemAtPath:toPath:error:
  • Previous by thread: Re: ScriptingBridge to access Mail Messages?
  • Next by thread: How do I use Sort Descriptor binding in IB on my array controller?
  • Index(es):
    • Date
    • Thread