Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook and VBA (http://www.outlookbanter.com/outlook-vba/)
-   -   How to find a contact in a contact list (http://www.outlookbanter.com/outlook-vba/85280-how-find-contact-contact-list.html)

Dan January 28th 09 07:12 PM

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!

Michael Bauer [MVP - Outlook] January 28th 09 08:30 PM

How to find a contact in a contact list
 


Please see the Restrict or Filter function in the VBA help file. You can
filter for the CompanyName property.

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: http://www.vboffice.net/product.html?pub=6&lang=en


Am Wed, 28 Jan 2009 11:12:02 -0800 schrieb Dan:

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!


Dan January 28th 09 08:57 PM

How to find a contact in a contact list
 
Michael,

Thank you for the suggestion. I'll check it out.

Dan

"Michael Bauer [MVP - Outlook]" wrote:



Please see the Restrict or Filter function in the VBA help file. You can
filter for the CompanyName property.

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: http://www.vboffice.net/product.html?pub=6&lang=en


Am Wed, 28 Jan 2009 11:12:02 -0800 schrieb Dan:

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!




All times are GMT +1. The time now is 05:04 AM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com