From Xojo Documentation

Revision as of 19:05, 3 September 2020 by THill (talk | contribs) (Text replacement - "{{Deprecated" to "{{DeprecatedItem")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Class (inherits from Object)

Provides the ability to read from and write to the macOS Address Book.

CurrentUser HasUnsavedChanges
Add Find Remove
Contacts Groups Save

Sample Code

You can create an instance of this class in either of two ways. Use the New operator in the usual way or call the AddressBook property of the System module.

Var book As New AddressBook
// or
Var book As AddressBook
book = System.AddressBook

You can obtain the contacts using the Contacts method. This code populates an the array of contacts from the user's Address Book.

Var book As AddressBook
book = System.AddressBook

Var contacts() As AddressBookContact
contacts = book.Contacts

Once you have the array of contacts, you can get its size with the Ubound function and use the properties of the AddressBookContact class to extract any field. The AddressBookData class is able to convert to a String automatically in most cases. If the field does not contain multiple values, it will return the string.

For example, you can loop through the array of AddressBookContacts and get the company names. This code puts the company names in a ListBox.

Var book As AddressBook
book = System.AddressBook

For Each Contact As AddressBookContact In book.Contacts

You can get the current user's "me" entry from this and extract a field:

Var book As AddressBook
book = System.AddressBook

Here is another way to get a property. It uses the Value method of the AddressBookData method.

Var book As AddressBook
book = System.AddressBook

See Also

AddressBookAddress, AddressBookContact, AddressBookData, AddressBookGroup, AddressBookRecord classes.