Search code examples
c#outlookvstooutlook-addincitrix

SetProperty / GetProperty on a mailItem does not work as expected when executed on Citrix


I have an Outlook VSTO plugin.

I use mailItem.PropertyAccessor.SetProperty (https://learn.microsoft.com/en-us/office/vba/api/outlook.propertyaccessor.setproperty) and mailItem.PropertyAccessor.GetProperty (https://learn.microsoft.com/en-us/office/vba/api/outlook.propertyaccessor.getproperty) in order to save and retrieve some information regarding mail items. and it's working just fine.

However, when (and only when) executed on a Citrix environment, SetProperty does not throw any error, and GetProperty act as if no property existed. So I don't have any error.

Any idea how to solve this issue ?


Solution

  • If is only for your internal purposes and it never needs to be saved, do not set the property - that can cause undesirable effects: the item becomes dirty, you waste a property mapping (you can have at most 0xFFFF named properties per mailbox - once you reach the limit, the mailbox is pretty much dead).

    Create a wrapper class that holds MailItem object as a property as well as a list or a dictionary or a set of explicit properties to hold your temporary per-item data.