Assign a custom form to existing Outlook items

Last reviewed on July 8, 2014

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")
'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.


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


More Information

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.

Written by

Diane Poremsky
A Microsoft Outlook Most Valuable Professional (MVP) since 1999, Diane is the author of several books, including Outlook 2013 Absolute Beginners Book. She also created video training CDs and online training classes for Microsoft Outlook. You can find her helping people online in Outlook Forums as well as in the Microsoft Answers and TechNet forums.

Please post long or more complicated questions at Outlookforums.

5 responses to “Assign a custom form to existing Outlook items”

  1. Rob

    I've seen about a dozen of similar posts but *NOT ONE* actually addresses this issue for Outlook 2010. And almost every post refers to MS articles that ALSO do not refer to Outlook 2010. I have to do this for my existing Calendar items for Outlook 2010 (change the message class) and I cannot find a properly described procedure.

  2. Robert Ogden

    Greetings Diane and other. I have an odd issue involvin VBA code that changes the MessageClass of 'Sent Item' messages in Outlook 2010.
    The code wirks fine, updates when it is run and the icon for the targeted 'Sent Item's updates. However, when I open the message that had its Message Class changed, it still will show the previous MessageClass. I have to select another mail folder (switching to Calendar, Contacts and Tasks folders don't always work the forst time), then come back to Sent Items and then open the item to see the change.

    The odd thing is, the trigger doesn't seem consistent. I'll change the Message Class, click on the 'Contacts' folder, then come back and open the Sent Message, it hasn't changed. However, sometimes when I do this, I'll come back and open the Sent Item, and it has changed. I've also let it sit for several minutes, but this never seem to update.

    Are there any suggestions on what may be going on here and how i can fire the 'Refresh' activity manually?

    Thanks for any help. ~R

  3. christopher koch

    I have tried DocMessageClass with Outlook 2013 and found it worked for me.

Leave a Reply

If the Post Coment button disappears, press your Tab key.