AddressBook

From Xojo Documentation
Jump to: navigation, search

Class (inherits from Object)

Provides the ability to read from and write to the Mac OS X Address Book.

Properties
CurrentUser HasUnsavedChanges


Methods
Add Find Remove
Contacts Groups Save


Examples

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.

Dim book as New AddressBook
// or
Dim 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.

Dim book as AddressBook
book=System.AddressBook

Dim 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.

Dim i as Integer
Dim book as AddressBook
book=System.AddressBook

Dim Contacts() as AddressBookContact
Contacts=book.Contacts
For i =0 to Ubound(Contacts)
ListBox1.Addrow Contacts(i).CompanyName
Next


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

Dim book as AddressBook
book=System.AddressBook
MsgBox book.CurrentUser.FirstName


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

Dim book as AddressBook
book=System.AddressBook
MsgBox book.CurrentUser.FirstName.Value


See Also

AddressBookAddress, AddressBookContact, AddressBookData, AddressBookGroup, AddressBookRecord classes.

Personal tools
Namespaces

Variants
Actions
Main
Content
Starting Out
Dig Deeper
More Help
Toolbox
About