/// <summary> ///Suppress User property when Printing. /// http://stackoverflow.com/questions/701508/suppressing-outlook-field-printing /// </summary> /// <param name= "UserProperty" ></param> Public Virtual voidsuppressuserpropertyprinting (OL. UserProperty UserProperty) {Try { if(UserProperty = =NULL)return;//no prop found//late Binding in. NET:http://support.microsoft.com/default.aspx?scid=kb; en-us;302902Type Userpropertytype; LongDispidmember =107; LongUlpropprintable =0x4;//removes Pdo_print_saveas stringDispmembername = String.Format ("[dispid={0}]", Dispidmember); Object[] dispparams; Userpropertytype= Userproperty.gettype ();//User Property Type//Call IDispatch::Invoke to get the current flags ObjectFlags = Userpropertytype.invokemember (Dispmembername, BindingFlags.GetProperty,NULL, UserProperty,NULL); //default is-//pdo_is_custom| pdo_print_saveas| Pdo_print_saveas_def//Ref:http://msdn.microsoft.com/en-us/library/ee415114.aspx LongLflags =Long. Parse (Flags. ToString ()); //Remove The Hidden property Printable flag//Change to -//pdo_is_custom| Pdo_print_saveas_def//Ref:http://msdn.microsoft.com/en-us/library/ee415114.aspxLflags &= ~ulpropprintable; //Place the new argument arrayDispparams =New Object[] {lflags}; //Call IDispatch::Invoke to set the current flagsUserpropertytype.invokemember (Dispmembername, BindingFlags.SetProperty,NULL, UserProperty, dispparams); } Catch{ }//safely ignore if property suppression doesn ' t work}
When printing Outlook Mail item, appointment item etc, the custom user defined fields would display. The above method Fixs this issue by change the update Flags from pdo_is_custom| pdo_print_saveas| Pdo_print_saveas_def to Pdo_is_custom| Pdo_print_saveas_def.
Suppress user properties/custom fields when print in Outlook