E
Ed Adamthwaite
Hi all,
I am wondering if there is a unique identifier for contacts in a MAPI
folder. I am using the function below to see if a Contact exists, however if
there are 2 "Fred Smiths" and the first one checked doesn't have the correct
Email1address, it won't check for existance of the second.
I cannot find a way to force a check for second existance of "Fred Smith".
Any ideas?
Thanks for any replies.
Ed.
Function DoesContactExist(FirstNameAndLastName As String, _
Email1address As String) As Boolean
On Error GoTo ErrorHandler
Dim olApp As Outlook.Application
Dim olNameSpace As NameSpace
Dim olFolder As Outlook.MAPIFolder
Set olApp = CreateObject("Outlook.Application")
Set olNameSpace = olApp.GetNamespace("MAPI")
Set olFolder = olNameSpace.GetDefaultFolder(olFolderContacts)
With olFolder
' Debug.Print "email is " & .Items(FirstNameAndLastName).Email1address
If .Items(FirstNameAndLastName).FullName = FirstNameAndLastName _
And .Items(FirstNameAndLastName).Email1address = Email1address Then
DoesContactExist = True
End If
End With
GoTo ThatsIt
ErrorHandler:
DoesContactExist = False
ThatsIt:
Set olFolder = Nothing
Set olNameSpace = Nothing
Set olApp = Nothing
End Function
I am wondering if there is a unique identifier for contacts in a MAPI
folder. I am using the function below to see if a Contact exists, however if
there are 2 "Fred Smiths" and the first one checked doesn't have the correct
Email1address, it won't check for existance of the second.
I cannot find a way to force a check for second existance of "Fred Smith".
Any ideas?
Thanks for any replies.
Ed.
Function DoesContactExist(FirstNameAndLastName As String, _
Email1address As String) As Boolean
On Error GoTo ErrorHandler
Dim olApp As Outlook.Application
Dim olNameSpace As NameSpace
Dim olFolder As Outlook.MAPIFolder
Set olApp = CreateObject("Outlook.Application")
Set olNameSpace = olApp.GetNamespace("MAPI")
Set olFolder = olNameSpace.GetDefaultFolder(olFolderContacts)
With olFolder
' Debug.Print "email is " & .Items(FirstNameAndLastName).Email1address
If .Items(FirstNameAndLastName).FullName = FirstNameAndLastName _
And .Items(FirstNameAndLastName).Email1address = Email1address Then
DoesContactExist = True
End If
End With
GoTo ThatsIt
ErrorHandler:
DoesContactExist = False
ThatsIt:
Set olFolder = Nothing
Set olNameSpace = Nothing
Set olApp = Nothing
End Function