Using the Outlook object model, how do I access the names of all of the user defined fields?

D

Dave

I need to get a list of the names of user defined fields in the Outlook
contacts folder.

These aren't the standard User1, User2 etc, fields but customer created
fields.

I can access there _values_ by creating a "Items" object and looping through
it like (very rough code):

Dim f as Outlook.MAPIFolder
Dim c as Outlook.ContactItem
Dim oItems as Outook.Items

Set oItems = f.Items
For i=1 to 10
If TypeName(oItems(i) = "ContactItem" Then
Set c=oItems(i)
Debug.Print c.UserProperties("CustomerPropertyName")
End If
Next i

What I am trying to do is loop through all the ContactItems.UserProperties
and list the names of all the user properties (in this example,
"CustomerPropertyName").

Can anyone give me some pointers on how to do this?
 
M

Michael Bauer

Hi Dave,

as for the contacts it works for all collections in the same way. Most
collections support a NewEnum method, so you can use "For Each" instead
of For i=...". For objects that´s faster.

Dim oProp as Outlook.UserProperty

For Each oProp In c.UserProperties
Debug.Print oProp.Name, oProp.Value
Next
 
D

Dave

viel Dank Michael


Michael Bauer said:
Hi Dave,

as for the contacts it works for all collections in the same way. Most
collections support a NewEnum method, so you can use "For Each" instead
of For i=...". For objects that´s faster.

Dim oProp as Outlook.UserProperty

For Each oProp In c.UserProperties
Debug.Print oProp.Name, oProp.Value
Next
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top