• MacTech Network:
  • Tech Support
  • |
  • MacForge.net
  • |
  • Apple News
  • |
  • Register Domains
  • |
  • SSL Certificates
  • |
  • iPod Deals
  • |
  • Mac Deals
  • |
  • Mac Book Shelf

MAC TECH

  • Home
  • Magazine
    • About MacTech in Print
    • Issue Table of Contents
    • Subscribe
    • Risk Free Sample
    • Back Issues
    • MacTech DVD
  • Archives
    • MacTech Print Archives
    • MacMod
    • MacTutor
    • FrameWorks
    • develop
  • Forums
  • News
    • MacTech News
    • MacTech Blog
    • MacTech Reviews and KoolTools
    • Whitepapers, Screencasts, Videos and Books
    • News Scanner
    • Rumors Scanner
    • Documentation Scanner
    • Submit News or PR
    • MacTech News List
  • Store
  • Apple Expo
    • by Category
    • by Company
    • by Product
  • Job Board
  • Editorial
    • Submit News or PR
    • Writer's Kit
    • Editorial Staff
    • Editorial Calendar
  • Advertising
    • Benefits of MacTech
    • Mechanicals and Submission
    • Dates and Deadlines
    • Submit Apple Expo Entry
  • User
    • Register for Ongoing Raffles
    • Register new user
    • Edit User Settings
    • Logout
  • Contact
    • Customer Service
    • Webmaster Feedback
    • Submit News or PR
    • Suggest an article
  • Connect Tools
    • MacTech Live Podcast
    • RSS Feeds
    • Twitter

Moving from Microsoft Office VBA to AppleScript:
MacTech's Guide to Making the Transition

Introduction  |  Table of Contents

Page Prev and Page Next buttons at bottom of the page.

Would you like a hard copy
or PDF of this Guide?

You can get a hard copy sent to you
AND download a PDF now ($19.95)
, or

... just download a PDF ($9.95).

Either way, you get a complimentary
MacTech Magazine Subscription

courtesy of the
Microsoft Mac Business Unit


 

  Magazine Reg. Price:  $50.00 value  
  Guide Reg. Price:  $40.00 value  
  You Save:  over $80.00!  

April, 2007
Page 123



Contacts and Groups (Address Book)

Make a New Contact

It is a simple matter to make a new contact. There are no fewer than 70 properties of contact (63 of which you can get via the handy property properties), and almost all of them are read-write. Fortunately, you don't have to set all of them! They all have defaults (almost all of which are ""), which do not need to be set. You can set as few properties as you want or have information for.

One thing that has changed in the latest versions of Entourage is that you have multiple address books (and calendars) if you have an Exchange account. (I would not be surprised if this were coming for local address books too in a later version.) If that applies to you, you would now have to specify in which address book you want to make the contact, or let it be the default location. (More on default location in a moment.)

As of Entourage 2004 v11.2, address book and calendar are now fully-fledged classes. Contacts are now elements of address book, not of the application as they used to be. In order not to break all the many scripts out there which simply make new contact and refer to contracts by name, not in an address book, the developers have cleverly allowed the old terminology to work by assuming a default address book.

If you do not have an Exchange account, you have only one address book, the local one "On My Computer". If you do have an Exchange account, your default address book is the one associated with your default mail account. If that's your Exchange account, then your default address book is your primary Exchange address book. If your default mail account is a POP or IMAP account, your default address book is your local one "On My Computer".

That means that you can still not specify a location at which to make contacts (and if you are still pre-v11.2 you must not do so, or your script will error) and they will still be made. If you have v11.2 or later, you can specify any of them. The way you refer to the local address book is

   address book 1

or

   address book id 14

The way you refer to an Exchange address book could be

   (get primary address book) of Exchange account 1

or

address book "Extra" of address book "Contacts" ¬

   of Exchange account "Name"

or any of the usual ways (by name, by index, by ID, by a whose filter).

Note that if you have nested "subfolder" Exchange address books as in the last example, they only show up that way (without any access to their contents) in the Folders List in the Mail area of Entourage. In the Address Book area they appear in a "flat" list. This is not Outlook. So 1) give your extra address books unique names and 2) if you have nested them as subfolders, you'll need to check the folder hierarchy in the Mail area before writing your script.

So, at the default address book:

tell application "Microsoft Entourage"

     set newContact to make new contact with properties ¬

          {first name:"Joe A.", last name:"Blow", home address:{street address:¬

              "123 Main Street", city:"Plainsville", state:"CA", zip:¬

              "98765", country:"USA"}, default postal address:¬

              home, home phone number:"(312) 555-1212", mobile phone number:¬

              "(312) 555-2323", category:{category "Family"}}

     set email1 to make new email address at newContact with properties ¬

          {label:home, contents:"jblow@aol.com"}

     set email2 to make new email address at newContact with properties ¬

          {label:work, contents:"jblow@jblowindustries.com"}

     set default email address of newContact to email1

end tell

Now you could just take a shortcut and set the email address property to "jblow@aol.com", rather than making email address elements afterwards. But then you could make only one of them that way and you couldn't set its label to home (it would be work, by default). It is a useful and quick shortcut when there's only one email address and you're happy for it to have the Work label.



< Previous Page Next Page>
 
MacTech Only Search:
Community Search:

 
 
 

 
 
 
 
 
  • SPREAD THE WORD:
  • Slashdot
  • Digg
  • Del.icio.us
  • Reddit
  • Newsvine
  • Generate a short URL for this page:



MacTech Magazine. www.mactech.com
Toll Free 877-MACTECH, Outside US/Canada: 805-494-9797
MacTech is a registered trademark of Xplain Corporation. Xplain, "The journal of Apple technology", Apple Expo, Explain It, MacDev, MacDev-1, THINK Reference, NetProfessional, Apple Expo, MacTech Central, MacTech Domains, MacNews, MacForge, and the MacTutorMan are trademarks or service marks of Xplain Corporation. Sprocket is a registered trademark of eSprocket Corporation. Other trademarks and copyrights appearing in this printing or software remain the property of their respective holders.
All contents are Copyright 1984-2010 by Xplain Corporation. All rights reserved. Theme designed by Icreon.
 
Nov. 20: Take Control of Syncing Data in Sow Leopard' released
Nov. 19: Cocktail 4.5 (Leopard Edition) released
Nov. 19: macProVideo offers new Cubase tutorials
Nov. 18: S Stardom anounces Safe Capsule, a companion piece for Apple's
Nov. 17: Ableton releases Max for Live
Nov. 17: Ableton releases Max for Live
Nov. 17: Ableton releases Max for Live
Nov. 17: Ableton releases Max for Live
Nov. 17: Ableton releases Max for Live
Nov. 17: Ableton releases Max for Live
Nov. 17: Ableton releases Max for Live
Nov. 17: Ableton releases Max for Live
Nov. 17: Ableton releases Max for Live
Nov. 17: Ableton releases Max for Live