Last reviewed on September 19, 2014   —  14 Comments

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.

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


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.


Comments

  1. Rob says

    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.

    • Diane Poremsky says

      The method is the same for any Outlook items type. Most methods that work in other versions of Outlook also work with 2010. My preferred method is DocMessageClass, but it won't work with 2013. For that I use the macro.

  2. Robert Ogden says

    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

    • Diane Poremsky says

      Which suite are you using? 32- or 64-bit? It could be the type of installation (click to run or MSI), bitness, or a recent Outlook update fixed it.

  3. abishek sharma says

    Hey Diane is it possible to modify just the global address list window which appears when we click the 'To' button on message window. We have a new requirement where the business wants to add some custom search and sorting functionality in the global address list.

    • Diane PoremskyDiane Poremsky says

      No, that is not possible. Administrators can control the fields displayed but you'd need to make a new form and intercept the call to add new features.

    • abishek sharma says

      Thanks Diane for your prompt reply. So you mean to say it is possible to design a new form and intercept the call from different events. Is it possible to completely replace the from with new form and hence not intercept the call from different events. In the process also replace the address list button on the ribbon of outlook home tab.

    • Diane PoremskyDiane Poremsky says

      I'm not sure if it is possible with the address book dialog, but that is how you would need to do it, if it is possible. I believe it will require extensive programming skills and will need to be in an addin - a macro won't do it.

  4. Dominik says

    hey diane, I wrote a piece of vba code to change the message class of all my contact items in a specific folder to display them in a custom form I've created. The code works fine and correctly but if I open a contact it is still displayed in a form I used before.

    • Diane PoremskyDiane Poremsky says

      Then it didn't work correctly. :) Do you get any error messages when you open it? Like one stating the form is not available. Have you tried deleting the Forms cache?

  5. Dominik says

    Hello,

    Our infrastructure:

    •Exchange Server 2010
    •Outlook 2010
    •Outlook 2013
    •Windows 7 Pro, Windows 8 Pro and Windows 8.1 Pro

    The situation:
    1.We've used an old custom form for contacts, worked perfectly fine
    2.I've updated the form (adding some new custom fields and checkboxes) using Outlook 2013 and publishing the form (with a new name) to the Exchange folder
    3.I've set the form as default form in our contacts folder
    4.I've used this Script to set the new form for the existing contacts and the name of the new form is saved correctly
    5.BUT if I open a contact in our Exchange contacts folder, Outlook 2013 (Outlook 2010) still shows the old form

    Steps I've taken so far:
    •Cleared Outlook forms cache
    •Repeated the above steps 1-4 in Outlook 2010
    •Switched Cached Exchange Mode off and back on
    •Allowed Scripts in Trust Center Settings
    •Used a new clean Windows installation with a new Outlook 2013 installation
    •Used different Exchange users on different systems, but some behavior when opening contacts

    I'm out of options I can think of, so maybe somebody else has some new view on this problem.

    Thank you very much in advance!

    Greetings,

    Karl

    • Diane PoremskyDiane Poremsky says

      The mailbox is an account, not a shared mailbox? There are issues with custom forms and shared mailboxes - data in custom fields isn't lose, but the contact may display on the standard form.

  6. Jack W says

    Hi Diane,

    I've cobbled together some code to populate some Outlook Appointment (calendar form) from a web-form produced standard email. The form uses the default add appointment form. I've tried lots and lost of ways to try and force the code to use a customized add appointment form (stored in the Personal Forms Library) but I can't get the code to use the custom form.

    If I can get that to work I want to populate some custom fields on the customized form from data extracted from the web-form produced standard email.

    In theory this should be easy!

    Any help to solve this would be much appreciated as I've been banging my head against a brick wall trying! :-/

Leave a Reply

Please post long or more complicated questions at OutlookForums by Slipstick.com.

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