UserProperties issue

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.
 
D

Dmitry Streblechenko

Move is a function that returns a new item in object in the destination
folder, not a sub.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
 
C

Craig Buchanan

Is there an async method that is called when the move() method has completed?

Thanks.
 
D

Dmitry Streblechenko

You will get an Items.ItemAdd event on teh target folder.
But what exactly are you trying to do? Move is a synchronous method, use it.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
 

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