Sub GetRecipients_Click
Address "CDORecipients","Recipients"
End Sub
'*********************************************************************
'Custom Procedure: Address
'Purpose: Display MAPI Address Book, allow user to select
'recipients, and then place recipient names in UD field.
'Aruguments: strUDFieldName, strShortName
'Returns: N/A
'*********************************************************************
Sub Address(strUDFieldName, strShortName)
Dim i
Dim strRecip
On Error Resume Next
strDialogCaption = "Select " & strUDFieldName
Set objCDO = Application.CreateObject("MAPI.Session")
'Piggyback on existing Outlook session
objCDO.Logon "", "", False, False, 0
If Err Then
MsgBox "Could not establish CDO session!", vbCritical
End If
Set Recips = objCDO.AddressBook(Nothing, _
strDialogCaption, False, True, 1, strShortName, "", "", 0)
'These recipients have been resolved by forceResolution argument above
If Not Err Then
For i = 1 To Recips.Count
strRecip = strRecip & Recips(i).Name & "; "
Next
If strRecip <> "" Then
strRecip = Left(strRecip, Len(strRecip)-2)
Userproperties(strUDFieldName) = strRecip
End If
End If
objCDO.Logoff
End Sub