zoukankan      html  css  js  c++  java
  • Suppress user properties/ custom fields when print in Outlook

            /// <summary>
            /// Suppress User Property when Printing.
            /// http://stackoverflow.com/questions/701508/suppressing-outlook-field-printing
            /// </summary>
            /// <param name="userProperty"></param>
            public virtual void SuppressUserPropertyPrinting(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;302902
                    Type userPropertyType;
                    long dispidMember = 107;
                    long ulPropPrintable = 0x4; // removes PDO_PRINT_SAVEAS
                    string dispMemberName = String.Format("[DispID={0}]", dispidMember);
                    object[] dispParams;
    
                    userPropertyType = userProperty.GetType(); // user property type
    
                    // Call IDispatch::Invoke to get the current flags
                    object flags = userPropertyType.InvokeMember(dispMemberName, BindingFlags.GetProperty, null, userProperty, null);
    
                    // default is 45 - 
                    // PDO_IS_CUSTOM|PDO_PRINT_SAVEAS|PDO_PRINT_SAVEAS_DEF
                    // ref: http://msdn.microsoft.com/en-us/library/ee415114.aspx
                    long lFlags = long.Parse(flags.ToString());
    
                    // Remove the hidden property Printable flag
                    // change to 41 - 
                    // PDO_IS_CUSTOM|PDO_PRINT_SAVEAS_DEF 
                    // ref: http://msdn.microsoft.com/en-us/library/ee415114.aspx
                    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, 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 will 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.

  • 相关阅读:
    memcached 在windows下安装及启动
    细说 ASP.NET Cache 及其高级用法
    asp.net MVC helper 和自定义函数@functions小结
    log4net 总结
    紧跟时代步伐,让我们拥抱MVC 3
    关于node-sass安装失败的解决办法
    table自适应
    获取select选中的值
    省市三级联动
    git bush 代码提交
  • 原文地址:https://www.cnblogs.com/yoyohappy/p/4654570.html
Copyright © 2011-2022 走看看