Wilson WindowWare Tech Support

WinBatch WinBatch+Compiler WebBatch
Home | Tech Database | Tech BBS | White Papers | Purchase


Get Outlook Contact information

 Keywords: OLE Outlook Contact 

Question:

I am trying to find an efficent way of getting a contact record from MS Outlook. I need to use the contact phone number as a reference to find the required contact. I have had a look through the documentation available but cannot find much information on this sort of usage.

In Outlook, as a VBA script it is posible to run the following script but this is not very easy to run from other applications outside Outlook and "Number To Find" needs to be a variable which seems difficult to acheive in VBA.

Sub FindContact()

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set myContacts = myNameSpace.GetDefaultFolder(olFolderContacts)

Set myItem = myContacts.Items.Find("[BusinessTelephoneNumber] =
""Number to find Here"" ")

myItem.Display

End Sub 

Can anyone think of an easier more portable way of getting an Outlook 97/2000 contact record displayed by using a telephone number as a reference to find the required contact?

Answer:

Seems like OLE should pretty much do it. See stuff like the OLE ADO CDO section under WinBatch in the Tech Support database area (http://techsupt.windowware.com). The following works with the current version of WinBatch:
olFolderContacts = 10 ;constant referencing the 'Contacts' folder
myOlApp = ObjectOpen("Outlook.Application")
myNameSpace = myOlApp.GetNamespace("MAPI")
myContacts = myNameSpace.GetDefaultFolder(olFolderContacts)

myItem = myContacts.Items
myFind = myItem.Find('[BusinessTelephoneNumber] = "(206) 937-9335" ')
myFind.Display



Article ID:   W14918