AddressBookData

From Xojo Documentation

Class (inherits from Object)


Used to manage Address Book fields that store multiple values, such as phone and fax numbers.

Methods
ActualLabel Insert Remove
Append Label Text
Count Name Value

Class Constants

The following class constants can be used to specify the Label parameter of the Insert or Append methods. Not all constants work with all data types. For example, AddressBookContact.EmailAddresses can only use LabelHome, LabelWork or LabelOther. If you use an invalid constant a RuntimeException is raised with the details in the Message/Reason properties.

Constant Description
LabelHome Home
LabelHomeFax Home Fax
LabelMain Main
LabelMobile Mobile phone
LabelOther Other
LabelPager Pager
LabelWork Work
LabelWorkFax Work Fax

Sample Code

The AddressBookData class can be used to get more information about a field (AddressBookContact properties). The Name method returns the property it represents. The Label method will return what kind of property it is, like Home, Work, etc. The Label property is relevant only for AddressBookData objects that can contain multiple values.

This code gets the user's phone numbers and displays them in a two-column ListBox. The first column displays the label ("Home", "Work", "Mobile", etc.) and the second column shows the phone number.

Dim book As New AddressBook
Dim data As AddressBookData
Dim c, i As Integer

data = Book.CurrentUser.PhoneNumbers
c = data.Count - 1
If data.Count > 0 Then
For i = 0 To c
ListBox1.AddRow(data.Label(i))
ListBox1.Cell(ListBox1.LastIndex, 1) = data.Value(i)
Next
Else
MsgBox("No phone numbers!")
End If

This method uses the Value method to get the current user's first email address.

Dim book As AddressBook
Dim myContact As AddressBookContact
book = System.AddressBook
myContact = Book.CurrentUser
MsgBox(myContact.EmailAddresses.Value(0))

See Also

AddressBook, AddressBookAddress, AddressBookContact, AddressBookGroup, AddressBookRecord classes.