I am trying to customize Outlook with a macro to add a UserProperty ("color"
to my MailItems and set it to e.g. "red". I run the following snippet:
references to this in the rest of my macro work fine, but when the macro terminates, I cannot see the property's value in outlook. I can see that a new property has been added to my "test" folder, but item 1 does not have the value "red" and if I run another macro with :
I get a "Object variable or With block variable not set" error. What am I doing wrong ?
Code:
Dim myNameSpace As NameSpace
Dim targetFolder As MAPIFolder
Dim myItem As MailItem
Dim myProp As UserProperty
Set myNameSpace = Application.GetNamespace("MAPI")
Set targetFolder = myNameSpace.Folders("Personal Folders").Folders("test")
Set myItem = targetFolder.Items(1)
Set myProp = myItem.UserProperties.Add("Color", olText)
myProp.Value = "red"
Code:
color = myItem.UserProperties("Color").Value