Name

Addressbook Functions — This section describes functions to use the addressbook for user and e-mail address lookups.

Synopsis

resource mapi_openaddressbook(mapisession $session);
resource mapi_ab_openentry(resource $addrbook,
                           string $entryid,
                           long $flags);

array mapi_ab_resolvename(resource $addrbook,
                          array $name_entry);

string mapi_ab_getdefaultdir(resource $addrbook);

Details

mapi_openaddressbook ()

resource mapi_openaddressbook(mapisession $session)

Opens the MAPI Addressbook. On Zarafa, this only is the Global Addressbook, containing the Zarafa users.

This function will return a MAPI Addressbook resource when successfull, or FALSE on failure.

$session
The MAPI Session that is opened before.

Example 3.65. Open the Addressbook

// First, logon to zarafa to get a session
$session = mapi_logon_zarafa($username, $password, $server);

// Now we can open the addressbook
$addrbook = mapi_openaddressbook($session);
		

mapi_ab_openentry ()

resource mapi_ab_openentry(resource $addrbook, string $entryid, long $flags)

Calls the OpenEntry() function on the Addressbook object.

This function performs the OpenEntry() call on the AddressBook interface. Returns FALSE on failure, otherwise an MailUser, DistList or ABContainer is returned as resource.

$addrbook
The Addressbook resource, retrieved with mapi_openaddressbook().
$entryid (optional)
This is the EntryID to request from the Addressbook. This can result in opening a MailUser, DistList or an Addressbook Container, which will be returned. When the EntryID is NULL, the top-level Addressbook Container is returned.
$flags (optional)
MAPI_BEST_ACCESS (default), MAPI_DEFERRED_ERRORS and/or MAPI_MODIFY.

Example 3.66. Requesting the top-level AddressBook container

$addrbook = mapi_openaddressbook($session);
$abcontainer = mapi_ab_openentry($addrbook);
		

mapi_ab_resolvename ()

array mapi_ab_resolvename(resource $addrbook, array $name_entry)

Calls the ResolveName() function on the Addressbook object.

This function performs the ResolveName() call on the AddressBook interface.

This function returns MAPI_E_AMBIGUOUS_RECEIP or MAPI_E_NOT_FOUND when these errors occurred, or FALSE on any other error. When the user is found, the array returned has the full information of the user requested.

$addrbook
The Addressbook resource, retrieved with mapi_openaddressbook().
$array
This is an array of arrays of properties, and will be converted to an AdrList structure. This structure will be used to find the given name of a user.

Example 3.67. Resolving a user to e-mail address

$addrbook = mapi_openaddressbook($session);
$user = array( array( PR_DISPLAY_NAME => 'steve' ), array( PR_DISPLAY_NAME => 'milo' ) );
$user = mapi_ab_resolvename($addrbook, $user);
print_r($user);
		

Output:

Array
(
    [0] => Array
        (
            [805437470] => SMTP
            [805371934] => Steve Hardy
            [956301315] => 0
            [805503006] => steve@connectux.com
            [268370178] => ...
            [267780354] => ...
            [268304387] => 6
            [267976962] => ...
            [806027522] => SMTP:STEVE@CONNECTUX.COM
        )

    [1] => Array
        (
            [805437470] => SMTP
            [805371934] => Milo Oostergo
            [956301315] => 0
            [805503006] => milo@connectux.com
            [268370178] => ...
            [267780354] => ...
            [268304387] => 6
            [267976962] => ...
            [806027522] => SMTP:MILO@CONNECTUX.COM
        )

)
		

mapi_ab_getdefaultdir ()

string mapi_ab_getdefaultdir(resource $addrbook)

Calls the GetDefaultDir() function on the Addressbook object.

This function performs the GetDefaultDir() call on the AddressBook interface.

This function returns an EntryID on success, FALSE on error.

$addrbook
The Addressbook resource, retrieved with mapi_openaddressbook().

Example 3.68. Opening the default Addressbook Directory

$addrbook = mapi_openaddressbook($session);
#entryid = mapi_ab_getdefaultdir($addrbook);