use*_*510 4 printing outlook interop mailitem
我编写了一个Outlook插件,该插件基本上允许通过Outlook接收的电子邮件与网站链接,以便也可以在网站的通讯功能中查看电子邮件。我将其他详细信息存储在MailItem的ItemProperties中,这些详细信息基本上是类似于网站中与电子邮件相关的用户ID之类的东西。
我遇到的问题是在打印电子邮件时,正在打印添加到MailItem的所有ItemProperties。有谁知道在打印电子邮件时如何排除自定义ItemProperty?
这是创建自定义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;
Run Code Online (Sandbox Code Playgroud)
小智 5
我正在研究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);
}
Run Code Online (Sandbox Code Playgroud)
确保_customProperty它是您通过以下代码创建的属性: mailItem.ItemProperties.Add(name,Microsoft.Office.Interop.Outlook.OlUserPropertyType.olText);
| 归档时间: |
|
| 查看次数: |
1528 次 |
| 最近记录: |