打印Outlook项目时隐藏CustomProperty

时间:2018-05-24 17:51:01

标签: outlook outlook-addin

我试图使用此处发布的代码来隐藏或禁用Outlook项目的customproperty的打印但是当我运行时我不断收到此错误:

{“方法'Needles.Infrastructure.Outlook.NeedlesCustomProperty。[DispID = 107]'找不到。”}

我创建的属性称为NeedlesCustomProperty。我在所有Outlook项目对象类型Mail,Cal和Task上创建此项。我正在使用的代码:

var item = outlookApplication.GetItemFromID(entryid); //verified returns correct item 

var property = item.GetNeedlesUserPropertyValue(false); //verified returns the custom property I create

long printablePropertyFlag = 0x4; // PDO_PRINT_SAVEAS

string printablePropertyCode = "[DispID=107]";

Type customPropertyType = property.GetType();

object rawFlags = customPropertyType.InvokeMember(printablePropertyCode, 
    BindingFlags.GetProperty, null, property, null);

long flags = long.Parse(rawFlags.ToString());

flags &= ~printablePropertyFlag;

object[] newParameters = new object[] { flags };

customPropertyType.InvokeMember(printablePropertyCode, BindingFlags.SetProperty, 
     null, property, newParameters);

想到我错过了什么?

0 个答案:

没有答案