PDA

Click to See Complete Forum and Search --> : Mapi Address Book


Stockcar
Jun 1st, 1999, 06:54 AM
Does anybody know how to access the Mapi address book. I am using the mapi session and message controls in a vb5 project. I can load up the address book, but how do I access the selected recipients ??

Thanks

Marc
Jul 14th, 1999, 08:35 PM
I use VB6 so I'm not for sure how it will work in VB5. Try this Function, where pName can either be "" or a partial name.

MailLogOn is a subroutine that verifies that the MAPI session is connected.

I hope this helps you.


Public Function GetAddressBook(pName) As String
Dim response As Integer
'Check if mail server is logged on already
MailLogOn

If pName = "" Then
pName = " "
End If

'Check names versus names in Address book of mail system
With MAPISession
'.Compose
.Compose
.RecipDisplayName = pName
.AddressResolveUI = True
On Error GoTo NameErr1
.ResolveName

If .RecipDisplayName <> pName Then
GetAddressBook = ExtractName(.RecipDisplayName)
End If
End With

ExitGet:
Exit Function

NameErr1:
Select Case Err()
Case Is = 32001
response = MsgBox("Must select a valid name from the address book.", vbCritical + vbRetryCancel, "User Name Error")
If response = vbRetry Then
Resume
Else
GetAddressBook = " "
Resume ExitGet
End If
End Select
End Function