A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook - Using Contacts
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

How to find a contact in a contact list



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old January 28th 09, 04:20 PM posted to microsoft.public.outlook.contacts
Dan
external usenet poster
 
Posts: 166
Default How to find a contact in a contact list

I have a list of contacts in my own database that I am accessing with a VB
program that I have written. I want to loop through this list and export them
to my Outlook 2007 contacts folder.

I am starting with the following code to access my Outlook folder:

Dim Contact As Outlook.ContactItem
Dim ContactList As Object
Dim ContactsFolder As Object
Dim OutlookApp As Object
Dim OutlookNamespace As Object

Set OutlookApp = GetObject(, "Outlook.Application")
Set OutlookNamespace = OutlookApp.GetNamespace("MAPI")
Set ContactsFolder = OutlookNamespace.GetDefaultFolder(olFolderContacts )
Set ContactList = ContactsFolder.Items

I need to find whether a contact is already in the ContactList based on the
CompanyName field. If it exists, I want to update certain fields in the
ContactItem. If it doesn't, I want to define a new ContactItem.

I have used collections very little, and so I'm not sure how to efficiently
find an item in the collection and know whether or not it exists. Thanks for
your help!
Ads
  #2  
Old January 28th 09, 06:25 PM posted to microsoft.public.outlook.contacts
Karl Timmermans
external usenet poster
 
Posts: 789
Default How to find a contact in a contact list

As Diane mentioned - code related questions should be posted in the
Outlook_Program_vba newsgroup - some very bright folks there that know
Outlook inside out. This group is primarily intended for Outlook users as it
relates to contacts. You should also check out the VB related newsgroups for
general programming topics.

But to get you started.......when you set your items you can include a
restriction on company name - that will give you all the contacts with the
same company and you'll need to determine from there if you're contact is in
there.:
Set ContactList = ContactsFolder.Items.Restrict("[CompanyName] = '" &
yourvalue & "'")

You may want to extend the restriction to include email address with the
company name to reduce the number of potential duplicates (not to mention
making sure that any duplicate is in fact related to the contact you want
to add or, for that matter, what you want to do if the same contact already
exists in the contact folder more than once or anything in between). Be
forewarned that the above can be a very slow way of doing things if you're
dealing with large data files and certainly may not be the most efficient of
approaches depending on the circumstances.

Karl
__________________________________________________ _
Karl Timmermans - The Claxton Group
ContactGenie - Importer 1.3 / DataPorter 2.0 / Exporter
"Power contact importers/exporters for MS Outlook '2000/2007"
http://www.contactgenie.com




"Dan" wrote in message
...
I have a list of contacts in my own database that I am accessing with a VB
program that I have written. I want to loop through this list and export
them
to my Outlook 2007 contacts folder.

I am starting with the following code to access my Outlook folder:

Dim Contact As Outlook.ContactItem
Dim ContactList As Object
Dim ContactsFolder As Object
Dim OutlookApp As Object
Dim OutlookNamespace As Object

Set OutlookApp = GetObject(, "Outlook.Application")
Set OutlookNamespace = OutlookApp.GetNamespace("MAPI")
Set ContactsFolder = OutlookNamespace.GetDefaultFolder(olFolderContacts )
Set ContactList = ContactsFolder.Items

I need to find whether a contact is already in the ContactList based on
the
CompanyName field. If it exists, I want to update certain fields in the
ContactItem. If it doesn't, I want to define a new ContactItem.

I have used collections very little, and so I'm not sure how to
efficiently
find an item in the collection and know whether or not it exists. Thanks
for
your help!



  #3  
Old January 28th 09, 07:09 PM posted to microsoft.public.outlook.contacts
Dan
external usenet poster
 
Posts: 166
Default How to find a contact in a contact list

Karl,

I'm sorry. I meant to post my question in the programming newsgroup and
didn't notice that I was in the wrong section.

Thanks for your suggestions. That helps to get me started, and I'll repost
my question in the other newsgroup to see if there are any other helpful
suggestions.

Dan

"Karl Timmermans" wrote:

As Diane mentioned - code related questions should be posted in the
Outlook_Program_vba newsgroup - some very bright folks there that know
Outlook inside out. This group is primarily intended for Outlook users as it
relates to contacts. You should also check out the VB related newsgroups for
general programming topics.

But to get you started.......when you set your items you can include a
restriction on company name - that will give you all the contacts with the
same company and you'll need to determine from there if you're contact is in
there.:
Set ContactList = ContactsFolder.Items.Restrict("[CompanyName] = '" &
yourvalue & "'")

You may want to extend the restriction to include email address with the
company name to reduce the number of potential duplicates (not to mention
making sure that any duplicate is in fact related to the contact you want
to add or, for that matter, what you want to do if the same contact already
exists in the contact folder more than once or anything in between). Be
forewarned that the above can be a very slow way of doing things if you're
dealing with large data files and certainly may not be the most efficient of
approaches depending on the circumstances.

Karl
__________________________________________________ _
Karl Timmermans - The Claxton Group
ContactGenie - Importer 1.3 / DataPorter 2.0 / Exporter
"Power contact importers/exporters for MS Outlook '2000/2007"
http://www.contactgenie.com




"Dan" wrote in message
...
I have a list of contacts in my own database that I am accessing with a VB
program that I have written. I want to loop through this list and export
them
to my Outlook 2007 contacts folder.

I am starting with the following code to access my Outlook folder:

Dim Contact As Outlook.ContactItem
Dim ContactList As Object
Dim ContactsFolder As Object
Dim OutlookApp As Object
Dim OutlookNamespace As Object

Set OutlookApp = GetObject(, "Outlook.Application")
Set OutlookNamespace = OutlookApp.GetNamespace("MAPI")
Set ContactsFolder = OutlookNamespace.GetDefaultFolder(olFolderContacts )
Set ContactList = ContactsFolder.Items

I need to find whether a contact is already in the ContactList based on
the
CompanyName field. If it exists, I want to update certain fields in the
ContactItem. If it doesn't, I want to define a new ContactItem.

I have used collections very little, and so I'm not sure how to
efficiently
find an item in the collection and know whether or not it exists. Thanks
for
your help!




 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to find a contact in a contact list Dan Outlook and VBA 2 January 28th 09 08:57 PM
Can you do a find and replace to a contact list in Outlook? Dental Smiles Outlook - Using Contacts 3 December 18th 07 09:35 PM
Can not find contact that exist in the contact list Chet Guzel Outlook - Using Contacts 0 July 31st 06 11:52 PM
Add Global Contact List to email find bxb7668 Outlook - Using Contacts 1 June 28th 06 02:56 AM
Can't find my contact list Ron Outlook - Using Contacts 5 April 18th 06 12:46 AM


All times are GMT +1. The time now is 06:34 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.