Referencing User-Defined Fields



Outlook 2003. I have created a custom contact form and added two
"user-defined" fields called "Employment Date" and "Spouse Birthday." How
may I programmatically reference these fields in a contact? For instance, in
the following code, how would I reference the fields?

Dim olApp As New Outlook.Application
Dim olNS As Outlook.Namespace
Dim ctFolder As Outlook.MAPIFolder
Dim ctFolderItems As Outlook.Items
Dim iterateCtItems As Integer
Dim countCtItems As Integer
Dim IC As Integer
Dim Criteria As String
Dim itm As Object

On Error Resume Next
Set olNS = olApp.GetNamespace("MAPI")
Set ctFolder = olNS.Folders("Public Folders")
Set ctFolder = ctFolder.Folders("All Public Folders")
Set ctFolder = ctFolder.Folders("Good News Contacts")
Set ctFolderItems = ctFolder.Items
countCtItems = ctFolderItems.Count
For Each itm In ctFolderItems
Debug.Print itm.FullName 'No problem for a standard contact field
Debug.Print itm.????????? 'What do I put for a user-defined


Use the UserProperties collection and UserProperty objects:

Dim objUPS As UserProperties
Dim objUP As UserProperty

Set objUPS = itm.UserProperties
Set objUP = objUPS.Item("MyCustomFieldName")
objUP.Value = "My test value"

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