'How can I add persistent data to a mail item so that it is not visible to the user
I have an Outlook add-in that collects data and processes it when the email is sent. Since the email may be saved and sent at a later date the data needs to be saved with the email Item.
Currently I am doing this by adding a user property which I then delete before the email is sent.
The only problem with this is that the user property is visible if the user wants to print the unsent email.
Does anybody know of a different way to do this or if there is a way to prevent my user property from being visible when printing?
Outlook.UserProperty mailUserProperty = currentMailItem.UserProperties.Add(MY_ATTACHMENT_PROPERTY, Outlook.OlUserPropertyType.olText);
mailUserProperty.Value = "Some Data";
Solution 1:[1]
Do not use UserProperties
collection to add / read the property. Instead, you can access the same property directly using MailItem.PropertyAccessor.GetProperty
/ SetProperty
. You can see the DASL property name (to be used in GetProperty
/ SetProperty
) in OutlookSpy (I am its author) - select a message with that property already set, click IMessage button on the OutlookSpy ribbon, select the custom property, see the DASL edit box.
OOM stores property definitions in a blob in a separate named property; the values are stored as regular named properties. As long as you do not add your property definition to that blob (that is what UserProperties.Add
does) and only set the value using the DASL name, Outlook won't know the property is there and won't print it.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |