4

我编写了一个 Outlook 插件,它基本上允许通过 Outlook 接收的电子邮件与网站链接,以便也可以在网站的通信功能中查看电子邮件。我在 MailItem 的 ItemProperties 中存储了其他详细信息,这些详细信息基本上就是电子邮件在网站中相关的用户 ID。

我遇到的问题是我添加到 MailItem 的任何 ItemProperties 都在打印电子邮件时被打印。有谁知道在打印电子邮件时如何排除自定义 ItemProperties?

下面是创建自定义 ItemProperty 的代码:

// Try and access the required property.
Microsoft.Office.Interop.Outlook.ItemProperty property = mailItem.ItemProperties[name];

// Required property doesnt exist so we'll create it on the fly.
if (property == null) property = mailItem.ItemProperties.Add(name, Microsoft.Office.Interop.Outlook.OlUserPropertyType.olText);

// Set the value.
property.Value = value;
4

2 回答 2

6

我正在开发 Outlook 扩展,有时我们遇到了同样的问题。我们的一位团队成员找到了解决方案。您可以创建一些负责禁用打印的方法。您可以在下面看到我们的代码的和平:

public void DisablePrint()
{
    long printablePropertyFlag = 0x4; // PDO_PRINT_SAVEAS
    string printablePropertyCode = "[DispID=107]";
    Type customPropertyType = _customProperty.GetType();

    // Get current flags.
    object rawFlags = customPropertyType.InvokeMember(printablePropertyCode , BindingFlags.GetProperty, null, _customProperty, null);
    long flags = long.Parse(rawFlags.ToString());

    // Remove printable flag.
    flags &= ~printablePropertyFlag;

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

    // Set current flags.
    customPropertyType.InvokeMember(printablePropertyCode, BindingFlags.SetProperty, null, _customProperty, newParameters);
}

确保 _customProperty 它是您通过以下代码创建的属性:mailItem.ItemProperties.Add(name,Microsoft.Office.Interop.Outlook.OlUserPropertyType.olText);

于 2016-09-01T10:53:03.403 回答
3

在低(扩展 MAPI)级别上,每个用户属性定义都有一个标志,用于确定它是否可打印。但是,该标志不会通过 Outlook 对象模型公开。

您可以解析用户属性 blob 并手动设置该标志(用户属性 blob 格式已记录,如果单击 IMessage 按钮,您可以在OutlookSpy中看到它),也可以使用Redemption及其RDOUserPropertyPrintable财产。

以下脚本 (VB) 将重置当前选定消息的所有用户属性的可打印属性:

  set Session = CreateObject("Redemption.RDOSession")
  Session.MAPIOBJECT = Application.Session.MAPIOBJECT
  set Msg = Session.GetMessageFromID(Application.ActiveExplorer.Selection(1).EntryID)
  for each prop in Msg.UserProperties
     Debug.Print prop.Name
     prop.Printable = false
  next
  Msg.Save
于 2013-05-09T19:01:08.220 回答