Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Transfer Contacts FROM Outlook TO Access

Status
Not open for further replies.

ajoyprabhu

Technical User
Sep 17, 2001
13
US
Hi all,

I have not seen an elegant solution for this problem-- I have various users that want to pool in thier Outlook contacts into one access database. I was thinking of having them setup a "Shared" folder in Outlook and using VBA import all the info into a table. Somethng like...

Get_Contact:
Dim appOutLook As Outlook.Application
Dim objContact As ContactItem
Dim objNameSpace As NameSpace
Dim objFolder As MAPIFolder

Set appOutLook = CreateObject("Outlook.Application")
Set objNameSpace = appOutLook.GetNamespace("MAPI")
Set objFolder = objNameSpace.GetDefaultFolder(olFolderContacts)

***NOT sure how to get the "Shared" folder name here ***

Dim MyRS As DAO.Recordset
Set MyRS = CurrentDb.OpenRecordset("Select * from Contacts", dbOpenDynaset)

Dim i As Long

For i = 1 To objFolder.Items.Count
With MyRS
***Here add for each outlook record... add new record***
.AddNew
![LastName] = .LastName ??? Not sure...
![EmailName] = .Email1Address ??? Not sure...
.Update
End With
Next

MyRS.Close
Set MyRS = Nothing

'release outlook
Set appOutLook = Nothing
Set objNameSpace = Nothing
Set objFolder = Nothing

How do I do this??? Thanks in advance.

Ajoy
 
OK I fugured it on my own...

Best to use the objFolder.Items.Find(sFilter) and find the contacts. I used the FileAs field and found records one at a time to insert into Access.

If anyone cares to see the code, I can paste the whole "with" loop here.

Ajoy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top