Here’s a weird one… we were adding user properties to a message using the IUserProperties interface, but whenever we did this the property would render when the message was printed. This included whenever the message was sent to a recipient within the same Exchange organisation.
Last time I had to ask Microsoft PSS to help was 1992, and in that case they were nice enough to send me a handcrafted sample application on a 3.5″ floppy. This time however they got back to me in a day with this little code snippet:
void MarkPropNoPrint(Outlook.MailItem message, string propertyName)
{
// Late Binding in .NET
// http://support.microsoft.com/default.aspx?scid=kb;EN-US;302902
Type userPropertyType;
long dispidMember = 107;
long ulPropPrintable = 0×4;
string dispMemberName = String.Format(”[DispID={0}]“, dispidMember);
object[] dispParams;
Microsoft.Office.Interop.Outlook.UserProperty userProperty = message.UserProperties[propertyName];
if (null == userProperty) return;
userPropertyType = userProperty.GetType();
// Call IDispatch::Invoke to get the current flags
object flags = userPropertyType.InvokeMember(dispMemberName, System.Reflection.BindingFlags.GetProperty, null, userProperty, null);
long lFlags = long.Parse(flags.ToString());
// Remove the hidden property Printable flag
lFlags &= ~ulPropPrintable;
// Place the new flags property into an argument array
dispParams = new object[] {lFlags};
// Call IDispatch::Invoke to set the current flags
userPropertyType.InvokeMember(dispMemberName,
System.Reflection.BindingFlags.SetProperty, null, userProperty, dispParams);
}
Srsly… there is no way I would have worked that out for myself…