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