Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 outlook contacts to access

Author  Topic 

rrb
SQLTeam Poet Laureate

1479 Posts

Posted - 2005-10-26 : 20:34:21
hi all

before you reply, yes I've seen the code examples , however, they all appear to have the outlook contact properties hardcoded...
eg c.FileAs, c.CreationTime etc
I am trying to create an access table to match the contact object, and so I want to iterate through each contact item's "properties" - only it doesn't have a properties collection. Or an items collection. I've also tried casting the contact to an object but that hasn't helped.

So my question - how do you iterate through all the "fields"/"properties" of an outlook contact, and determine their type and size?

PS - for those of you skim reading, as I've said above, I've already tried c.properties etc

PPS - I don't want the UserProperties collection, I want the collection of "hardcoded" contact properties

PPPS - the inbuilt "export" function only exports a subset of the properties....

--
I hope that when I die someone will say of me "That guy sure owed me a lot of money"

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2005-10-26 : 21:57:04
Have you ever seen/tried this:

Go to tables, right-click, choose "Link" (or Import), then in the file-type drop-down box, you will see two options you may not have noticed before:

OutLook()
Exchange()

Try selecting either one of those. You can then link directly to contacts and query it and append to local tables (or import) or do whatever you need. Note that I haven't done this in a while and I am typing this from home where I cannot test it, but I know it has worked for me in the past when I thought my only option was VBA.
Go to Top of Page

rrb
SQLTeam Poet Laureate

1479 Posts

Posted - 2005-10-26 : 22:04:17
Yep, I have seen that, but unfortunately, I need to do it with VBA...

--
I hope that when I die someone will say of me "That guy sure owed me a lot of money"
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2005-10-26 : 22:08:35
Why can't you use it? You can link to the tables needed in Access and then open the linked table using VBA and enumerate the columns using ADO recordset classes ... Otherwise, if that won't work, can you give some more info?
Go to Top of Page

rrb
SQLTeam Poet Laureate

1479 Posts

Posted - 2005-10-26 : 22:15:12
Well, maybe I can, except then I need to update the connect properties of the linked table, depending on what folders the user has in their outlook address book.

I was planning to write code to create the table based on the fields that were in the default contacts folder instead - because then the Access VBA code would be indpendent of the outlook version....

--
I hope that when I die someone will say of me "That guy sure owed me a lot of money"
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2005-10-26 : 23:07:55
Here's some Outlook VBA code that should get you started:
Dim a As ContactItem, b As ItemProperty
Set a = Application.CreateItem(olContactItem)
For Each b In a.ItemProperties
MsgBox b.Name
Next
Set a = Nothing
Set b = Nothing
Obviously it doesn't do much, but you can figure out the rest.
Go to Top of Page

rrb
SQLTeam Poet Laureate

1479 Posts

Posted - 2005-10-26 : 23:14:30
Hey rob

what library is ItemProperty from? I get "user-defined type not defined"

--
I hope that when I die someone will say of me "That guy sure owed me a lot of money"
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2005-10-26 : 23:36:45
Gotta reference the Outlook library in your VB/VBA project. Works in Outlook 2003, should work in earlier versions too.

Might need to preface some of the objects with "Outlook." when you define them.
Go to Top of Page

rrb
SQLTeam Poet Laureate

1479 Posts

Posted - 2005-10-26 : 23:44:20
Yep, I have Microsoft Outlook 9.0 Object Library selected (or I would have failed when viewing the "hard-coded" contact properties), but it aint in that one.

Must have been exposed only for Outlook 2003?

--
I hope that when I die someone will say of me "That guy sure owed me a lot of money"
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2005-10-26 : 23:47:52
Hmmm, well, at least after 9.0. As long as there is an ItemProperties collection on the ContactItem object, you can Dim b as Object instead, the rest of the code should be fine.
Go to Top of Page

rrb
SQLTeam Poet Laureate

1479 Posts

Posted - 2005-10-26 : 23:53:42
Thanks matey - just my bad luck. I look forward to upgrading!!

Cheers

--
I hope that when I die someone will say of me "That guy sure owed me a lot of money"
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2005-10-27 : 00:06:15
BTW Rob if you get stuck try this site:

http://www.slipstick.com/index.htm

And there's also:

http://www.mvps.org/links.html#Outlook
http://www.mvps.org/access/
Go to Top of Page

rrb
SQLTeam Poet Laureate

1479 Posts

Posted - 2005-10-27 : 00:09:26
thanks rob, you're a champ

--
I hope that when I die someone will say of me "That guy sure owed me a lot of money"
Go to Top of Page
   

- Advertisement -