1

I'm working on WPF application in C#. Some time ago I had a problem with sending an encrypted email through the Outlook. The problem was strongly related to the encryption method - the S/MIME standard.

After that it came to my attention there's an other option for encrypting emails in the company I work for. It comes in Outlook 365 and it's called Microsoft Purview Message Encryption. It can be enabled by choosing Encrypt-Only option under Encrypt dropdown. More here and here.

I find is very suitable for my solution as it seems to be faster and eliminates problem with expired/missing recipients' certificates.

The way I was handling the encryption so far was as follows, through the OOM, setting flags in the MailItem object:

using Outlook = Microsoft.Office.Interop.Outlook;

(...)
    
    Outlook.Application olkApp = new Outlook.Application();
    Outlook.MailItem otlMail = olkApp.CreateItemFromTemplate(templateFullPath) as Outlook.MailItem;

    otlMail.To = (...)

    try
    {
        const string PR_SECURITY_FLAGS = http://schemas.microsoft.com/mapi/proptag/0x6E010003";
        long prop = Convert.ToInt64(otlMail.PropertyAccessor.GetProperty(PR_SECURITY_FLAGS));
        var ulFlags = 0x0;
        ulFlags = (ulFlags | 0x1); //  SECFLAG_ENCRYPTED
                                   //ulFlags = (ulFlags | 0x2); //  SECFLAG_SIGNED
        otlMail.PropertyAccessor.SetProperty(PR_SECURITY_FLAGS, ulFlags);
    }
    catch (Exception ex)

(...)

    try
    {
        otlMail.Send();
    }
    catch (Exception ex)
    {
        (...)
    }

Unfortunately, with this way emails seems to stick with S/MIME. Even though I was trying to remove this kind of encryption through Outlook's options: (File -> Options -> Trust Center -> Email Security -> delete Default Setting), so that in new email's options was only "Encrypt-Only" option (along with Do Not Forward), and hoping the Outlook will encrypt it with new feature. Bad luck. It kept coming back.

I neither can find any useful information for developers about this feature.

Can anyone help please? Is it possible to send Encrypt-Only email through Outlook Object Model or other programming means in C#?

Regards, Kris

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
krzyhur
  • 11
  • 2
  • Try to compare sent items using MFCMAPI or OutlookSpy. Is there any difference between encrypted and plain messages in Outlook? – Eugene Astafiev Sep 05 '22 at 18:07

1 Answers1

0

The Outlook object model doesn't provide anything for that. That's an Office 365 feature (AIP).

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45