Discussion Locked

VB & Outlook / Exchange GAL

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I have VB 6.0 & I would like to read the the name or other field of all the member of a distribution list of Outlook / Exchange GAL.

Can anyone help.

Thanks

3 replies

by rrv

Use the code below
Set Con = CreateObject("ADODB.Connection")
Con.Provider = "ADsDSOObject"
Con.Open
Set Cmd = CreateObject("ADODB.Command")
Set Cmd.ActiveConnection = Con
Cmd.CommandText = ";(objectClass=organizationalPerson);cn,givenName,sn;subtree"
Cmd.Properties("Page Size") = 99
Set Rs = Cmd.Execute 'Here Rs is ADODB.Recordset
Set ExchgGrd.DataSource = Rs 'Here ExchgGrd is MSHFlexgrid control
Rs.Close
Set Rs = Nothing

So u got what you wanted as VB Code.
All the best
RV

by rakeshkanojia

Hi RVLion,

I'am able to connect to Exchange there is no problem but my problem is how to access fileds from the GAL.

e.g. MsgBox objAddressEntry.fields(CdoPR_HOME_TELEPHONE_NUMBER)

"GET ERROR [Collaboration Data Objects - [MAPI_E_NOT_FOUND(8004010F)]]

===============================
Const CdoPR_ACCOUNT = &H3A00001E 'Alias
Const CdoPR_HOME_TELEPHONE_NUMBER = &H3A09001E 'Phone
Const CdoPR_HOME_FAX_NUMBER = &H3A25001E 'Home Fax

Const strServer = "TEST"
Const strMailbox = "MAILBOX"

Dim strProfileInfo As String

Set objSession = CreateObject("MAPI.Session")

strProfileInfo = strServer & vbLf & strMailbox
objSession.Logon ProfileInfo:=strServer &vbLf & strMailbox
Set objAddrEntries = objSession.AddressLists("Global Address List").AddressEntries

Ctr = 1

For Each objAddressEntry In objAddrEntries
MsgBox objAddressEntry.Name & " " & objAddressEntry.fields(CdoPR_ACCOUNT) 'This is fine

MsgBox objAddressEntry.fields(CdoPR_HOME_TELEPHONE_NUMBER) "GET ERROR [Collaboration Data Objects - [MAPI_E_NOT_FOUND(8004010F)]]

Ctr = Ctr + 1
If Ctr = 5 Then
Exit Sub
End If
Next

This discussion is closed to new replies.