This thread was originaly in the Access VBA
thread705-1592612
Anyone know a way to validate email addresses against the Exchange server GAL??
Without importing into access.
I have a need where only requests from "valid" emails can be processed. In this case a 'valid' email is one that is listed in the Exchange Server GAL.
And yes this is VERY big. Requests for information come in from every state.
So what I want to be able to do is this.
Once a request has been input, the Contacts email address is then looked up in the Exchange GAL to make sure the person requesting the information is a current employee. If not, through an error message to the user stating the the email address is either invalid or not present in the GAL.
Here is as close as I can seem to get.
But it retrieves only the first instance of a name.
Code:
Function GetOutlookAddress(strContactName As String)
Dim outApp As Object, outNS As Outlook.NameSpace
Dim myAddressList As Outlook.AddressList
Set outApp = CreateObject("Outlook.Application")
Set outNS = outApp.GetNamespace("MAPI")
Set myAddressList = outNS.Session.AddressLists("Global Address List")
Set strUser = myAddressList.AddressEntries(strContactName)
' Debug.Print myAddressList.AddressEntries("fuh")
' Debug.Print "Name:.......... " & myAddressList.Name
' Debug.Print "Application:... " & myAddressList.Application
' Debug.Print "Class:......... " & myAddressList.Class
' Debug.Print "ID:............ " & myAddressList.ID
' Debug.Print "Index:......... " & myAddressList.Index
' Debug.Print "Session:....... " & myAddressList.Session
' Debug.Print "Session:....... " & myAddressList.Parent
' Debug.Print "Name Search:... " & myAddressList.AddressEntries("fuhrman")
' Debug.Print "Name Search:... " & myAddressList.AddressEntries(strContactName)
Debug.Print strUser
Set outApp = Nothing
End Function
If the myAddressList.AddressEntries(strContactName) is returning an array I cannot get it to display each entry using a for each loop.
Can someone help with this.. PLEEEEEAAAASSSSEEEE!!!!!!!!
Code:
Sub GetUserName()
Dim strName As String
strName = InputBox(Prompt:="Your name please.", _
title:="ENTER YOUR NAME", Default:="Your Name here")
Call GetOutlookAddress(strName)
' If strName = "Your Name here" Or _
' strName = vbNullString Then
' Exit Sub
' Else
'
'' Select Case strName
'' Case "Bob"
'' 'Do Bobs stuff
'' Case "Bill"
'' 'Do Bills stuff
'' Case "Mary"
'' 'Do Marys stuff
'' Case Else
'' 'Do other stuff
'' End Select
'
'
'
' End If
End Sub
On the new contact form users put in the contacts email address and then are required to manually verify it against the Exchange GAL before they can process the incoming request. If the contact is not in the Exchange GAL the Rep's are not allowed to process the request. I would like to automate the GAL lookup and verify name and contact information against it.
Thanks
John Fuhrman
faq329-6766
faq329-7301
thread329-1334328
thread329-1424438
thread705-1592825