One of my favorite (and free!) little utilities is DocMessageClass as it makes it easy to change the message class on existing items to use a new published form. Unfortunately, it doesn't work with Outlook 2013.
Although not quite as easy to use as DocMessageClass, you can use a macro to make the change in all versions, including Outlook 2013.
Note: these methods work for any Outlook item, not just contacts.
This first macro is based off of a macro provided by Microsoft, intended to be used in a template (see the KB article for details if you want to run it from a template.
Sub ChangeContactMessageClass() ' Change the following line to your new Message Class NewMC = "IPM.Contact.Test" Set CurFolder = Application.ActiveExplorer.CurrentFolder Set AllItems = CurFolder.Items NumItems = CurFolder.Items.count ' Loop through all of the items in the folder For i = 1 To NumItems Set CurItem = AllItems.Item(i) ' Test for a distlist If CurItem.Class = olContact Then ' Test to see if the Message Class needs to be changed If CurItem.MessageClass <> NewMC Then ' Change the Message Class CurItem.MessageClass = NewMC ' Save the changed item CurItem.Save End If End If Next MsgBox "Done." End Sub
To use the code above with non-contact folders, remove the If CurItem.Class = olContact Then line and the second End If.
Macro alternative to DocMessageClass
This alternative to DocMessageClass was posted by chaplaindoug in Outlook Forums: How to Set Existing Contacts to Custom Form
This macro shows how to use change the message class of Public Folder contacts.
Sub ChangeMessageClass() UName = Environ("UserName") Set olNS = Application.GetNamespace("MAPI") Set ContactsFolder = olNS.Folders("Public Folders - " + UName + "@goodnewsjail.org") Set ContactsFolder = ContactsFolder.Folders("All Public Folders") Set ContactsFolder = ContactsFolder.Folders("Good News Contacts") 'to use on the default contacts folder instead, uncomment this line 'Set ContactsFolder = olNS.GetDefaultFolder(olFolderContacts) Set ContactItems = ContactsFolder.Items For Each itm In ContactItems If itm.MessageClass = "IPM.Contact" Then itm.MessageClass = "IPM.Contact.Good News Contact" itm.Save End If Next End Sub
Change message class as item is saved
If you need to change the message class on some items, you can use an ItemAdd macro to change the message class when the new item is saved.
This could be used with an If statement to change the message class according to a value in a field (for example, If item.country = "Canada"), or when a new item is created in such a way that the custom form is not used.
Option Explicit Private WithEvents newContacts As Outlook.Items Private Sub Application_Startup() Set newContacts = Session.GetDefaultFolder(olFolderContacts).Items End Sub Private Sub newContacts_ItemAdd(ByVal Item As Object) If Item.Class = "IPM.Distlist" Then Exit Sub Dim NewMC As String NewMC = "IPM.Contact.MapIt" If Item.Class = olContact Then If Item.MessageClass <> NewMC Then Item.MessageClass = NewMC Item.Save End If End If End Sub
Change the message class when a contact is edited
This macro changes the message class when you edit and save a contact.
Public WithEvents cItems As Outlook.Items Public Sub Initialize_handler() Set cItems = Application.ActiveExplorer.CurrentFolder.Items End Sub Sub cItems_ItemChange(ByVal Item As Object) ' Change the following line to your new Message Class NewMC = "IPM.Contact.robert-form" If Item.Class = olContact Then If Item.MessageClass <> NewMC Then Item.MessageClass = NewMC Item.Save End If End If End Sub
How to use the Macro
First: You will need macro security set to low during testing.
To check your macro security in Outlook 2010 and newer, go to File, Options, Trust Center and open Trust Center Settings, and change the Macro Settings. In Outlook 2007 and older, it’s at Tools, Macro Security. If Outlook tells you it needs to be restarted, close and reopen Outlook. Note: after you test the macro and see that it works, you can either leave macro security set to low or sign the macro.
Now open the VBA Editor by pressing Alt+F11 on your keyboard.
To put the code in a module:
- Right click on Project1 and choose Insert > Module
- Copy and paste the macro into the new module.
More information as well as screenshots are at How to use the VBA Editor.
How to update existing items in an Outlook folder to use a new custom form This code works in all versions of Outlook and can be run using Run This Form from the forms designer. However, if you use it on Contacts, it does not detect Distribution lists and turns them into contacts. The first code on the page above uses the same code and adds a check for distribution lists.