AddressBookData
From Xojo Documentation
This item was deprecated in version 2019r2. |
This class is only available on the macOS platform. For cross-platform compatibility, use #If...#Endif with the Target... specifiers to make sure you will not attempt to use this class on an incompatible platform. |
Used to manage Address Book fields that store multiple values, such as phone and fax numbers.
Methods | |||||||||
|
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 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 myContact As AddressBookContact
book = System.AddressBook
myContact = Book.CurrentUser
MsgBox(myContact.EmailAddresses.Value(0))
See Also
AddressBook, AddressBookAddress, AddressBookContact, AddressBookGroup, AddressBookRecord classes.