• Outlook User
  • New Outlook app
  • Outlook.com
  • Outlook Mac
  • Outlook & iCloud
  • Developer
  • Microsoft 365 Admin
    • Common Problems
    • Microsoft 365
    • Outlook BCM
    • Utilities & Addins

Assign a custom form to existing Outlook items

Slipstick Systems

› Developer › Assign a custom form to existing Outlook items

Last reviewed on March 16, 2022     28 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 64-bit versions of Outlook (which is the default install for new computers.) If you have 32-bit Office installed, you can use DocMessageClass.

Although not quite as easy to use as DocMessageClass, you can use a macro or PowerShell script to change the message class in all versions, including Outlook 2013 and newer.

Note: these methods work for any Outlook item, not just contacts.

Using PowerShell to change the message class

You can use PowerShell to change the message class. The first example changes the message class of all Contact items, while the second one changes a specific message class.

# Change the message class of all contacts
$olApp = new-object -comobject outlook.application
$namespace = $olApp.GetNamespace("MAPI")

# Default Contacts folder
$Contacts = $namespace.GetDefaultFolder(10)

foreach ($Contact in $Contacts.Items)
{

# Don't change distribution lists
    if ($Contact.messageclass -notlike "*distlist*")
    {
              
   $Contact.messageclass  = "IPM.Contact.form-name"  
   $Contact.Save()

    }
}

$olApp.Quit | Out-Null
[GC]::Collect()

Change specific message classes

Use this macro to change specific message classes to another message class.

# Change the message class of all contacts
$olApp = new-object -comobject outlook.application
$namespace = $olApp.GetNamespace("MAPI")

# Default Contacts folder
$Contacts = $namespace.GetDefaultFolder(10)

foreach ($Contact in $Contacts.Items)
{

# Don't change distribution lists, change specific class
    if ($Contact.messageclass -notlike "*distlist*" -or $Contact.messageclass -like "*new*")
    {
  
   $Contact.messageclass  = "IPM.Contact.form-name"  
   $Contact.Save()

    }
}

$olApp.Quit | Out-Null
[GC]::Collect()

Run on a non-default folder

This code sample is from Kenny in our forum.
can't get custom form to update multiple contacts using VBA

To use, enter the name of the folder in the code. The folder does not need to be selected before running the PowerShell.

# Change the message class of all contacts
$olApp = new-object -comobject outlook.application
$namespace = $olApp.GetNamespace("MAPI")
$Contacts = $namespace.GetDefaultFolder(10)
# Specify target folder
$myNewFolder = $Contacts.Folders("subfolder name")

foreach ($Contact in $myNewFolder.Items)
{
# Don't change distribution lists
if ($Contact.messageclass -notlike "*distlist*")
{
# specify new message subclass
$Contact.messageclass = "IPM.Contact.custom-form-name"
$Contact.Save()
}
}
$olApp.Quit | Out-Null
[GC]::Collect()

 

Change the message class of the selected folder

This version of the PowerShell works with the selected folder. Select a folder then run the macro.

# Change the message class of all contacts
$olApp = new-object -comobject outlook.application
$Contacts = ($olApp.ActiveExplorer()).CurrentFolder

Write-Host "Current folder is $Contacts"
foreach ($Contact in $Contacts.Items) {
# Don't change distribution lists
if ($Contact.messageclass -notlike "*distlist*")
{
# Specify new message subclass
$Contact.messageclass = "IPM.Contact.custom-form-name"
$Contact.Save()
}
}
$olApp.Quit | Out-Null
[GC]::Collect()

Change message class on selected items

This PowerShell will change the message class on the select items.

# Change the message class of all contacts
$olApp = new-object -comobject outlook.application
$namespace = $olApp.GetNamespace("MAPI")

$currentExplorer = ($olApp.ActiveExplorer())
$Selection = $currentExplorer.Selection

write-host $selection.count

foreach ($Contact in $Selection)
{
# Don't change distribution lists
if ($Contact.messageclass -notlike "*distlist*")
{
# specify new message subclass
$Contact.messageclass = "IPM.Contact"
$Contact.Save()
}
}
$olApp.Quit | Out-Null
[GC]::Collec

Using PowerShell Scripts

To use, right-click on the Start menu in Windows 10 and click on the Windows PowerShell entry. Paste the entire script in the PowerShell window and press Enter.
bulk change contact fields

If you want to save the script as a .ps1 file, paste it into Notepad and save it with the extension .ps1. To open it in the PowerShell IDE, type powershell on the start menu and click on Windows PowerShell IDE when the PowerShell app is found. Paste the script in the editing window.

To use it, you need to allow local scripts by running this command:

Set-ExecutionPolicy RemoteSigned

To run your saved .ps1 file, right-click on the script and choose Run with PowerShell.

 

Using VBA to change the message class

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:

  1. Right click on Project1 and choose Insert > Module
  2. Copy and paste the macro into the new module.

More information as well as screenshots are at How to use the VBA Editor.

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.

Assign a custom form to existing Outlook items was last modified: March 16th, 2022 by Diane Poremsky

Related Posts:

  • Use PowerShell to Bulk Change Contacts
  • Create new Outlook folders using PowerShell
  • This macro scans all messages in a folder, looking for a unique keywor
    Assign a keyword to a message field for tracking
  • How to Set a Custom Form as the Default for a Folder

About 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.

Subscribe
Notify of
28 Comments
newest
oldest most voted
Inline Feedbacks
View all comments

Andrew Juby
February 7, 2022 3:41 am

Hello,
I am changing my IPM.contacts for a custom form, so that all my old items open on the custom form. I have not used VBA before, have done some programming 30 years ago.
I've had a few problems.
I've just found out that my Outlook is 32bit, so have run the Doc Message program. This has reset my icons again and now I can open all items again with my custom form.
I have lost my Distribution lists because of some incorrect programming. Is there a way I can change a particular Item back to a distribution list... IPM.Contact.DistList. Do it one by one? I've appreciated the help received going through your forum. Wish I had some time to do some VBA learning...
Thanks for all your help. Andrew

0
0
Reply
Biagio Lucci
October 16, 2019 1:14 pm

Hello there
Help me out please.
Outlook 2016 32 bit and need to apply a form when an item is saved. The item is a task and I don't know how to switch the wording in the macro for that.
please help

thanks

0
0
Reply
Diane Poremsky
Author
Reply to  Biagio Lucci
October 17, 2019 12:04 am

yoiu'd use IPM.Tasks.form-name

To find the form name, if you have an item saved using the form, add the message class field to the view. if the form is published, you can get the form name in File > options > advanced > custom forms.

0
0
Reply
Carlos
June 9, 2016 6:12 pm

Outlook 2016
HELP PLEASE
I used the first macro... by mistake... I was trying to open the code to edit it but instead it ran with the default IPM.Contact.Test as the NewMC. I was able to abort it, but it changed about half of my calendar items to contacts. Next, I changed the NewMC to IPM.Schedule_Production_3, which is the custom form which I wanted to convert everything to in the first place, but the macro will not run. I enabled macros and tried again with no luck. If it is a custom form do I need to specify a path? Any advice would be greatly appreciated.

0
0
Reply
Diane Poremsky
Author
Reply to  Carlos
June 9, 2016 11:02 pm

Did it not run or just not make any changes?
Is that the right form name? If it's based on an appointment form, it should be IPM.Appointment.Schedule_Production_3

0
0
Reply
Kevin
April 11, 2016 2:03 pm

I've successfully set up a new form for a Calendar (Outlook 2013, non-profit E1 Office 365 Exchange) and made it the default. Works well however if recurrence is used the original form is opened. Any suggestions about changing this to open the form I created instead of the default?

0
0
Reply
Diane Poremsky
Author
Reply to  Kevin
June 16, 2016 12:07 am

This happens only when you are opening the recurring event to view it, not when composing?

0
0
Reply
Oliver
October 15, 2015 4:09 pm

thanks. I understand I have just to use your last script.
where should I add my form name, which is fxtest

0
0
Reply
Oliver
October 14, 2015 5:38 pm

in case it does no work and that creates a mess, can you help me out to go back...? I'm afraid I can mess something that is very valuable to me.
I also understand that I keep all the blue stuff. I delete those three lines, and the ' before the other line, then I create a module and Paste the script and then I run the script. And then if it works when I open an old contact I'll see my form

are my presumptions ok?

0
0
Reply
Diane Poremsky
Author
Reply to  Oliver
October 14, 2015 9:11 pm

Correct, you'll use this code on the default contacts folder (using the name of your form) and when it's finished, when you open a contact it will use your custom form.

Sub ChangeMessageClass()
Set olNS = Application.GetNamespace("MAPI")
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

0
0
Reply
Oliver
October 14, 2015 12:45 pm

If I want to use the chaplingdoug's macro after following your suggested deletions, should I also change whatever is in blue font, user name. Also somewhere should I add the name of my custom form.
Sorry but I want to be completely sure that I'm doing the right stuff. I tried at another contact folder and now I don't know how to fix it, I mean I cannot open correctly the contacts.

0
0
Reply
Diane Poremsky
Author
Reply to  Oliver
October 14, 2015 3:48 pm

if you are using your default contacts folder this is all you need to identify the folder to use:
Set ContactsFolder = olNS.GetDefaultFolder(olFolderContacts)

the blue text part is used to identify an Exchange public folder contacts list.

0
0
Reply
Oliver
October 13, 2015 9:04 pm

I have Outlook 2016 x64 not exchange
I'm not an expertise.
which would be the macro to assign my form to all existing contacts.
I saw here posted a macro created by chaplaindoug however I don't know in which way should I tweak it in order to have it work. I tried a couple of tweaks and I couldn't. thanks

0
0
Reply
Diane Poremsky
Author
Reply to  Oliver
October 13, 2015 11:13 pm

If you aren't using Exchange, use the first macro on the page or to use chaplindoug's macro, delete the first 3 "Set ContactsFolder" lines and remove the apostrophe from in front of Set ContactsFolder = olNS.GetDefaultFolder(olFolderContacts) - the macro will work on the default contacts folder.

0
0
Reply

Visit Slipstick Forums.
What's New at Slipstick.com

Latest EMO: Vol. 30 Issue 36

Subscribe to Exchange Messaging Outlook






Support Services

Do you need help setting up Outlook, moving your email to a new computer, migrating or configuring Office 365, or just need some one-on-one assistance?

Our Sponsors

CompanionLink
ReliefJet
  • Popular
  • Latest
  • Week Month All
  • Use Classic Outlook, not New Outlook
  • How to Remove the Primary Account from Outlook
  • Reset the New Outlook Profile
  • This operation has been cancelled due to restrictions
  • Adjusting Outlook's Zoom Setting in Email
  • Disable "Always ask before opening" Dialog
  • How to Hide or Delete Outlook's Default Folders
  • Removing Suggested Accounts in New Outlook
  • Remove a password from an Outlook *.pst File
  • Syncing Outlook with an Android smartphone
  • Opt out of Microsoft 365 Companion Apps
  • Mail Templates in Outlook for Windows (and Web)
  • Urban legend: Microsoft Deletes Old Outlook.com Messages
  • Buttons in the New Message Notifications
  • Move Deleted Items to Another Folder Automatically
  • Open Outlook Templates using PowerShell
  • Count and List Folders in Classic Outlook
  • Google Workspace and Outlook with POP Mail
  • Import EML Files into New Outlook
  • Opening PST files in New Outlook
Ajax spinner

Recent Bugs List

Microsoft keeps a running list of issues affecting recently released updates at Fixes or workarounds for recent issues in classic Outlook (Windows).

For new Outlook for Windows: Fixes or workarounds for recent issues in new Outlook for Windows .

Outlook for Mac Recent issues: Fixes or workarounds for recent issues in Outlook for Mac

Outlook.com Recent issues: Fixes or workarounds for recent issues on Outlook.com

Office Update History

Update history for supported Office versions is at Update history for Office

Outlook Suggestions and Feedback

Outlook Feedback covers Outlook as an email client, including Outlook Android, iOS, Mac, and Windows clients, as well as the browser extension (PWA) and Outlook on the web.

Outlook (new) Feedback. Use this for feedback and suggestions for Outlook (new).

Use Outlook.com Feedback for suggestions or feedback about Outlook.com accounts.

Other Microsoft 365 applications and services




New Outlook Articles

Opt out of Microsoft 365 Companion Apps

Mail Templates in Outlook for Windows (and Web)

Urban legend: Microsoft Deletes Old Outlook.com Messages

Buttons in the New Message Notifications

Move Deleted Items to Another Folder Automatically

Open Outlook Templates using PowerShell

Count and List Folders in Classic Outlook

Google Workspace and Outlook with POP Mail

Import EML Files into New Outlook

Opening PST files in New Outlook

Newest Code Samples

Open Outlook Templates using PowerShell

Count and List Folders in Classic Outlook

Insert Word Document into Email using VBA

Warn Before Deleting a Contact

Use PowerShell to Delete Attachments

Remove RE:, FWD:, and Other Prefixes from Subject Line

Change the Mailing Address Using PowerShell

Categorize @Mentioned Messages

Send an Email When You Open Outlook

Delete Old Calendar Events using VBA

VBA Basics

How to use the VBA Editor

Work with open item or selected item

Working with All Items in a Folder or Selected Items

VBA and non-default Outlook Folders

Backup and save your Outlook VBA macros

Get text using Left, Right, Mid, Len, InStr

Using Arrays in Outlook macros

Use RegEx to extract message text

Paste clipboard contents

Windows Folder Picker

Custom Forms

Designing Microsoft Outlook Forms

Set a custom form as default

Developer Resources

Developer Resources

Developer Tools

VBOffice.net samples

SlovakTech.com

Outlook MVP David Lee

Repair PST

Convert an OST to PST

Repair damaged PST file

Repair large PST File

Remove password from PST

Merge Two Data Files

Sync & Share Outlook Data

  • Share Calendar & Contacts
  • Synchronize two computers
  • Sync Calendar and Contacts Using Outlook.com
  • Sync Outlook & Android Devices
  • Sync Google Calendar with Outlook
  • Access Folders in Other Users Mailboxes

Diane Poremsky [Outlook MVP]

Make a donation

Mail Tools

Sending and Retrieval Tools

Mass Mail Tools

Compose Tools

Duplicate Remover Tools

Mail Tools for Outlook

Online Services

Calendar Tools

Schedule Management

Calendar Printing Tools

Calendar Reminder Tools

Calendar Dates & Data

Time and Billing Tools

Meeting Productivity Tools

Duplicate Remover Tools

Productivity

Productivity Tools

Automatic Message Processing Tools

Special Function Automatic Processing Tools

Housekeeping and Message Management

Task Tools

Project and Business Management Tools

Choosing the Folder to Save a Sent Message In

Run Rules on messages after reading

Help & Suggestions

Submit Outlook Feature Requests

Slipstick Support Services

Buy Microsoft 365 Office Software and Services

Visit Slipstick Forums.

What's New at Slipstick.com

Home | Outlook User | Exchange Administrator | Office 365 | Outlook.com | Outlook Developer
Outlook for Mac | Common Problems | Utilities & Addins | Tutorials
Outlook & iCloud Issues | Outlook Apps
EMO Archives | About Slipstick | Slipstick Forums
Submit New or Updated Outlook and Exchange Server Utilities

Send comments using our Feedback page
Copyright © 2025 Slipstick Systems. All rights reserved.
Slipstick Systems is not affiliated with Microsoft Corporation.

:wpds_smile::wpds_grin::wpds_wink::wpds_mrgreen::wpds_neutral::wpds_twisted::wpds_arrow::wpds_shock::wpds_unamused::wpds_cool::wpds_evil::wpds_oops::wpds_razz::wpds_roll::wpds_cry::wpds_eek::wpds_lol::wpds_mad::wpds_sad::wpds_exclamation::wpds_question::wpds_idea::wpds_hmm::wpds_beg::wpds_whew::wpds_chuckle::wpds_silly::wpds_envy::wpds_shutmouth:
wpDiscuz

Sign up for Exchange Messaging Outlook

Our weekly Outlook & Exchange newsletter (bi-weekly during the summer)






Please note: If you subscribed to Exchange Messaging Outlook before August 2019, please re-subscribe.

Never see this message again.

You are going to send email to

Move Comment