Search code examples
vbaemailencryptionoutlook

Encrypt Outlook Mail Programmatically via VBA


I am looking for a way to encrypt and send Outlook mail via VBA code in Outlook 2013.

I was hoping I could access the mail object and call something like an "encrypt" Method.

Microsoft says, that "The Microsoft Outlook object model does not provide direct support to sign or encrypt mail messages programmatically", but it is possible to build a solution for it. (https://support.microsoft.com/de-de/help/2636465/how-to-sign-or-encrypt-mail-messages-programmatically)

I know I can encrypt mails manually, but I would like to access it programmatically. Perhaps I can call like an event or something that is called when this property is set.

I do not have any Certificates. Is there even a way to encrypt mails in Outlook without using Certificates?


Solution

  • You will need to set the PR_SECURITY_FLAGS property. See https://blogs.msdn.microsoft.com/dvespa/2009/03/16/how-to-sign-or-encrypt-a-message-programmatically-from-oom/ for an example.