4

Outlook 経由で受信した電子メールを基本的に Web サイトにリンクできるようにする Outlook プラグインを作成し、Web サイトの通信機能でも電子メールを表示できるようにしました。MailItem の ItemProperties 内に追加の詳細を保存します。これらの詳細は基本的に、Web サイト内で電子メールが関連するユーザーの 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 拡張機能に取り組んでいますが、以前にも同じ問題が発生することがありました。私たちのチーム メンバーの 1 人が解決策を見つけました。印刷を無効にするメソッドを作成できます。以下のコードの平和を見ることができます:

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とそのRDOUserPropertyを使用できます。Printable財産。

次のスクリプト (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 に答える