Outlook fails to find contact 
Author Message
 Outlook fails to find contact

Hello

I have a simple function in VBA to find if contact exist or not.

Private Function ContactExists(ByVal Email As String) As Boolean
  Dim NameSpace as NameSpace
  Dim CFolder As MAPIFolder
  Dim Contact As ContactItem

  Set NameSpace = Application.GetNamespace("MAPI")
  Set CFolder = NameSpace.GetDefaultFolder (olFolderContacts )
  Set Contact = CFolder.Items.Find("[Email1Address]=" & Email)
  If Contact Is Nothing Then
    ContactExists = False
  Else
    ContactExists = True
  End If
  Exit Function


function works, but if mailbox name contains a point "." , for example


Can anybody help?
Thank you



Thu, 18 Sep 2003 15:01:10 GMT  
 Outlook fails to find contact
Hi,

have you found a solution?

Greetings, Patrick.

Quote:
-----Original Message-----

Hello

I have a simple function in VBA to find if contact exist or not.

Private Function ContactExists(ByVal Email As String) As Boolean
  Dim NameSpace as NameSpace
  Dim CFolder As MAPIFolder
  Dim Contact As ContactItem

  Set NameSpace = Application.GetNamespace("MAPI")
  Set CFolder = NameSpace.GetDefaultFolder (olFolderContacts )
  Set Contact = CFolder.Items.Find("[Email1Address]=" & Email)
  If Contact Is Nothing Then
    ContactExists = False
  Else
    ContactExists = True
  End If
  Exit Function


function works, but if mailbox name contains a point "." , for example


Can anybody help?
Thank you

.



Sat, 18 Oct 2003 20:57:28 GMT  
 Outlook fails to find contact
The code is missing the required quotes around the email address:

Set Contact = CFolder.Items.Find("[Email1Address] = " & AddQuotes(Email))

where AddQuotes() is this function:

Function AddQuotes(MyText) As String
    AddQuote = Chr(34) & MyText & Chr(34)
End Function

--

Sue Mosher, Outlook MVP
Author of
     Teach Yourself Microsoft Outlook 2000 Programming in 24 Hours
     Microsoft Outlook 2000 E-mail and Fax Guide
Outlook and Exchange solutions at http://www.slipstick.com


Quote:
> Hi,

> have you found a solution?

> Greetings, Patrick.

> -----Original Message-----
> Hello

> I have a simple function in VBA to find if contact exist or not.

> Private Function ContactExists(ByVal Email As String) As Boolean
>   Dim NameSpace as NameSpace
>   Dim CFolder As MAPIFolder
>   Dim Contact As ContactItem

>   Set NameSpace = Application.GetNamespace("MAPI")
>   Set CFolder = NameSpace.GetDefaultFolder (olFolderContacts )
>   Set Contact = CFolder.Items.Find("[Email1Address]=" & Email)
>   If Contact Is Nothing Then
>     ContactExists = False
>   Else
>     ContactExists = True
>   End If
>   Exit Function


> function works, but if mailbox name contains a point "." , for example


> Can anybody help?
> Thank you

> .



Sat, 18 Oct 2003 21:21:29 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Outlook fails to find contact

2. Find a contact in Outlook contact or in a access database

3. Find method of Outlook.MAPIFolder fails intermittently

4. best way to sync Outlook contacts with a SQL Server contacts database

5. VB send outlook contact to contacts subfolder?

6. Prob : Adding contacts for Outlook 2000 and Outlook 97

7. Transferring standard contact data from standard contact forms into contact custom forms

8. vba items.find how to find a quoted word within a subject in outlook

9. Export Access Contacts To Outlook

10. Select contact sub-folder In Outlook

11. Attach Outlook contact to email

12. Remove Outlook Contact from Access

 

 
Powered by phpBB® Forum Software