How to sign or encrypt a message programmatically from OOM
Q: How do I signal to Outlook to sign and / or encrypt a message from the Outlook object model?
A: There is not a first-class object or property to do this within the object model. However, you can set the MAPI property PR_SECURITY_FLAGS. The code below demonstrates this using the PropertyAccessor object:
Sub SignAndEncrypt()
Const PR_SECURITY_FLAGS = "schemas.microsoft.com/mapi/proptag/0x6E010003"
Dim mi As MailItem
Set mi = Application.ActiveInspector.CurrentItem
Dim prop As Long
prop = CLng(mi.PropertyAccessor.GetProperty(PR_SECURITY_FLAGS))
ulFlags = ulFlags Or &H1 ' SECFLAG_ENCRYPTED
ulFlags = ulFlags Or &H2 ' SECFLAG_SIGNED
mi.PropertyAccessor.SetProperty PR_SECURITY_FLAGS, ulFlags
Set mi = Nothing
End Sub