gpt4 book ai didi

printing - 从打印中隐藏自定义 ItemProperties。互操作展望

转载 作者:行者123 更新时间:2023-12-03 06:32:41 24 4
gpt4 key购买 nike

我编写了一个 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;

最佳答案

我正在开发 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);

关于printing - 从打印中隐藏自定义 ItemProperties。互操作展望,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16468819/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com