T
Tim Johnson
Hi there,
I have written a function that performs a search through Outlook's GAL using
a person's name as the search field and returning their email address. It
works fine, except for the pesky Outlook security prompt. I have a copy of
Redemption with which I can bypass this, but am unsure which objects to use
and how to set them. I have posted the code below, any assistance in
correctly setting the appropriate Redemption objects is greatly appreciated.
Thanks in advance.
Code:
Function GAL(strName As String) As String
Dim strEnt As String, intCnt As Integer
Set olApp = CreateObject("Outlook.Application")
Set olLst = olApp.Session.AddressLists("Global Address List")
Set olEnts = olLst.AddressEntries
For Each olEnt In olEnts
If olEnt.Name Like "*" & strName & "*" Then
intCnt = intCnt + 1
strEnt = Right(olEnt.Address, Len(olEnt.Address) - InStr(1,
olEnt.Address, "Recipients/cn=") + 1)
strEnt = Replace(strEnt, "Recipients/cn=", "") & "@domain.com"
Debug.Print strEnt
End If
Next olEnt
If intCnt = 1 Then
GAL = strEnt
Else
MsgBox "There are multiple entries in the Global Address List that " _
& "contain that name. Please verify that the email is correct." _
, , "Multiple Names Found"
GAL = strEnt
End If
End Function
I have written a function that performs a search through Outlook's GAL using
a person's name as the search field and returning their email address. It
works fine, except for the pesky Outlook security prompt. I have a copy of
Redemption with which I can bypass this, but am unsure which objects to use
and how to set them. I have posted the code below, any assistance in
correctly setting the appropriate Redemption objects is greatly appreciated.
Thanks in advance.
Code:
Function GAL(strName As String) As String
Dim strEnt As String, intCnt As Integer
Set olApp = CreateObject("Outlook.Application")
Set olLst = olApp.Session.AddressLists("Global Address List")
Set olEnts = olLst.AddressEntries
For Each olEnt In olEnts
If olEnt.Name Like "*" & strName & "*" Then
intCnt = intCnt + 1
strEnt = Right(olEnt.Address, Len(olEnt.Address) - InStr(1,
olEnt.Address, "Recipients/cn=") + 1)
strEnt = Replace(strEnt, "Recipients/cn=", "") & "@domain.com"
Debug.Print strEnt
End If
Next olEnt
If intCnt = 1 Then
GAL = strEnt
Else
MsgBox "There are multiple entries in the Global Address List that " _
& "contain that name. Please verify that the email is correct." _
, , "Multiple Names Found"
GAL = strEnt
End If
End Function