Certain Unicode characters are replaced with question marks for text properties set using UserProperties.Add


When trying to retrieve text UserProperty values via the Outlook Object Model from signed or encrypted messages, if the values contain extended Unicode characters, you will notice that certain characters are replaced by the question mark “?” symbol.

For example, you use the following code to create a UserProperty object named myUserProperty. You then set the value of this property to “My property value ❶ é ⅓ ؜” and you save the message:

Outlook.UserProperty userProperty;
userProperty = currentMailItem.UserProperties.Add("myUserProperty", Microsoft.Office.Interop.Outlook.OlUserPropertyType.olText);
userProperty.Value = "My property value ❶ é ① ⅓ ؜";

You then either sign or encrypt the message and you send it.

If you then use the following code to retrieve the property value, you will notice that the userProperty.Value string value is “My property value ? é ? ? ?” instead of the value you’ve originally set.

Outlook.UserProperty userProperty = currentMailItem.UserProperties.Find("myUserProperty");


Use the PropertyAccessor object for creating custom properties, instead of UserProperties.

For example:

Outlook.PropertyAccessor propertyAccessor = currentMailItem.PropertyAccessor;
propertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/myUserProperty", "My property value ❶ é ① ⅓ ؜");

In the above example, http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046} is the property schema for the PS_PUBLIC_STRINGS property.

To retrieve the property value, use the following code:

Outlook.PropertyAccessor propertyAccessor = currentMailItem.PropertyAccessor;
dynamic propertyValue = propertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/myUserProperty");
Comments (0)

Skip to main content