Opening encrypted emails with C #

I work in Visual Studio 2012 to create a relatively simple add-in for Outlook 2010. The machines are Win 7 Enterprise 32 and 64. The purpose of the add-in is to decrypt email messages directly in the user's mailbox, so that they can be easily found in .pst or save unencrypted files in network folders as .msg files. Emails are encrypted using PKK x.509 with private keys stored on a smart card that asks the user for a PIN code each time the encrypted email is opened. This is what I have so far:

private void buttonDecrypt_Click(object sender, RibbonControlEventArgs e)    {
  currentExplorer = Globals.ThisAddIn.Application.ActiveExplorer();
  if (currentExplorer.Selection.Count > 0)      {
    for (int i = 0; i < currentExplorer.Selection.Count; i++)        {
      Object selObject = currentExplorer.Selection[i+1];
      if (selObject is Microsoft.Office.Interop.Outlook.MailItem)          {
        Microsoft.Office.Interop.Outlook.MailItem mailItem = 
          (selObject as Microsoft.Office.Interop.Outlook.MailItem);      
        mailItem.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/proptag/0x6E010003", 0);
        mailItem.Save();
      }                    
    }                
  }
}

Outlook, PIN-, . , , , , , . , , mailItem.PropertyAccessor.Setproperty() COMException was unhandled by user code: Your Digital ID name cannot be found by the underlying security system. , PIN- .

+4
1

, Outlook. OOM IPM.Note. , IMessage MAPI MailItem.MAPIOBJECT.

PR_SECURITY_FLAGS, Outlook , . , - . - , / Outlook; , MailItem.PropertyAccessor.

P7M, / . OutlookSpy: IMessage OutlookSpy ( MailItem.MAPIOBJECT), . IMAPISecureMesage IMessage IMAPIFolder | GetContentsTable P7M.

, MAPI (++ Delphi), , Redemption ( RDOSession.GetMessageFromID). Redemption RDOEncryptedMesage, .

+1

Source: https://habr.com/ru/post/1568221/


All Articles