C
Craig Buchanan
I am trying to convert a MailItem to a ContactItem programatically and set
two user-defined properties. I do this by moving the MailItem to the
Contacts folder, then add the UDPs. While the UDPs appear to be added in the
code, the properties are not displayed when I view the UDFs for the contact
in Outlook. Here's the code:
Dim ci As Outlook.MailItem = mailItem.Copy
With ci
'move the mailItem to the Contacts folder, which creates a contact
..Move(Me.Destination)
'test for existence of UDP, create and populate if it doesn't exist
If .UserProperties.Item("User Property") Is Nothing Then
..UserProperties.Add("User Property", Outlook.OlUserPropertyType.olText, False)
..UserProperties.Item("User Property").Value = "my user property"
End If
'test for existence of UDP, create and populate if it doesn't exist
If .UserProperties.Item("Folder Property") Is Nothing Then
..UserProperties.Add("Folder Property", Outlook.OlUserPropertyType.olText,
True)
..UserProperties.Item("Folder Property").Value = "my folder property"
End If
'save changes
..Save()
End With
Thoughts are appreciated. Thanks.
two user-defined properties. I do this by moving the MailItem to the
Contacts folder, then add the UDPs. While the UDPs appear to be added in the
code, the properties are not displayed when I view the UDFs for the contact
in Outlook. Here's the code:
Dim ci As Outlook.MailItem = mailItem.Copy
With ci
'move the mailItem to the Contacts folder, which creates a contact
..Move(Me.Destination)
'test for existence of UDP, create and populate if it doesn't exist
If .UserProperties.Item("User Property") Is Nothing Then
..UserProperties.Add("User Property", Outlook.OlUserPropertyType.olText, False)
..UserProperties.Item("User Property").Value = "my user property"
End If
'test for existence of UDP, create and populate if it doesn't exist
If .UserProperties.Item("Folder Property") Is Nothing Then
..UserProperties.Add("Folder Property", Outlook.OlUserPropertyType.olText,
True)
..UserProperties.Item("Folder Property").Value = "my folder property"
End If
'save changes
..Save()
End With
Thoughts are appreciated. Thanks.