IRM Tip - Macro to make every mail protected.
People have been asking how they can force users to IRM protect every message that goes out.
Well here is some simple sample code. WARNING: I am lazy and do no error checking in my sample code...do not follow my lead. Use this as intended..a sample.
The code here is just for VBA, but you can write a VB6 COM application if you want, that would be better for the masses, and not require people to downgrade their macro security.
For Outlook 2003: (This is kind of a ‘hack’ because the IRM interfaces aren't exposed in 2003, but should work)
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim oCBs As CommandBars
Dim oPerm As CommandBarControl
Dim oDNF As CommandBarControl
Set oCBs=Item.GetInspector.CommandBars
Set oPerm=oCBs(“Menu Bar”).Controls(“File”).Controls(“Permission”)
Set oDNF=oPerm.Controls(“Do Not Forward”)
oDNF.Execute
End Sub
For Outlook 2007: (In 2007 it is part of the object model)
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Item.PermissionService=olWindows ‘ Could use olPassport if you want
Item.Permission=olDoNotForward
End Sub
If you wanted as I said you could write a VB6 COM Add-In (because it is easy, check out KB316983 for details), and check which version of Outlook the user is using with Application.Version, and then execute the correct code for the version they have.
Thanks.
-Jason
Comments
Anonymous
January 01, 2003
Jason - I realise this is an old post but I'm wondering if you can help? Do you know how this code can be adapted to allow a different RMS template to be applied to the mail? The Permission propery can be set to olPermissionTemplate but I can't see how to set the RMS template name that should be used? Any ideas or suggestions would be great. Thanks PhilipAnonymous
January 01, 2003
I have tried to use your code but it is not encrypting any of the messages. I have watched it cycle through the code step by step but it never actually protects the message. Please help!