How to change the default item type of a folder (VBScript and OOM, or EWS)


It is possible to change the default item type of Outlook folders, and this is commonly done when custom forms are being used.  The question came up recently asking whether it is possible to do this programmatically, and it certainly is.

The default item type of a folder is stored in a single MAPI property, PidTagDefaultPostMessageClass (as described here), so to change the default item type you just need to update this property.  Note that this property might not actually exist on a folder, and if it doesn’t then the default item type will depend upon the type of folder (which is identified by the PidTagContainerClass property).

My first thoughts were to use the Outlook Object Model, and it is a very simple script to do this (see attached).  The problem with this approach is that it is not easy to deploy such a solution.  It could be run as a log-on script or similar, but there are many situations where this may have unexpected consequences (if the user has multiple profiles, for example, or even no profile).  So, for a solution that doesn’t involve user interaction EWS is an easy solution for Exchange 2007 and above.

Also in the attached file is a console application (with full source code) written in C# and using the EWS Managed API that demonstrates how to modify the property using EWS.  It accepts parameters, and can be automated very easily.  It will look up the primary SMTP address of the current user and use this information to access the mailbox using EWS. The command-line syntax is:

UpdateFolderItemType Folder ItemType [EWSUrl] [SkipCertificateValidation]

Folder                       : one of inbox, calendar, contacts, notes, tasks
ItemType                     : the required default item type (if it contains spaces this should be quoted)
[EWSUrl]                     : optional EWS URL.  If this is missing, autodiscover is used.
[SkipCertificationValidation]: if true, then any certificate errors are ignored (useful for testing in a lab environment)

If needed, the code could be adapted to be run from a central location and access mailboxes using impersonation (i.e. an administrator could run it instead of requiring it to be run from the user’s profile).

UpdateFolderItemType.zip

Comments (2)

  1. i3laze says:

    Hi there) Very helpful! Saved my day.

    In my case I was fixing Exchange mailboxes..

    Had to use OutlookSpy plugin to figure out correct schema and ItemType (mine was IPF.Note, not IPM.Note).

    Here's updated script to fix Inbox, SentMail, Outbox and Junk types to default IPF.Note ("E-Mail"):

    yadi.sk/…/uFiy_r_OjJ3ce

  2. PidTagContainerClass will contain IPF.Note or the appropriate type for that folder.  PidTagDefaultPostMessageClass should contain IPM.Note (if the property exists), as it is defining the default message class (not specifying the type of folder).  This information can be found in the links above to the documentation.

Skip to main content