After importing IMAP folders into Exchange mailboxes, users often discover their mail is not visible. This is because the exported folders retained the properties and views associated with the IMAP account. The default IMAP view is Hide messages marked for deletion and Exchange doesn't support marking messages, so the view hides all messages. By changing the view to IMAP messages in View, Change View, the messages are visible. They are also visible if you view the folder in OWA.
If you have Compact as view option, apply it to a folder then apply that view to the rest of the folders.
Imported folders will use IMAP views and say "Filter Applied" in the status bar, as seen in this screenshot, and of course, no messages are visible in the folder.
To fix this, you can edit the folder property using MFCMAPI or change the property using a macro, PowerShell, or a VBScript.
PowerShell and VBScript won't require you to change macro security, you just need to run the script. The VBScript only changes the selected folder, while the PowerShell script will change all subfolders under the selected folder.
I also have two macros below, the first macro changes only the selected folder's PR_CONTAINER_CLASS property to IPF.Note if the folder type is IPF.Imap. The second macro checks the folder and subfolders.
Once the folder's class is changed and you refresh the folder, the Views available are the normal folder views. (Select a different folder than the one you changed to refresh the folder.)
VBScript
To use this VBScript, copy and paste into Notepad then save with the .vbs extension. Select the folder you need to change then double click to run it the VBS.
PropName = "http://schemas.microsoft.com/mapi/proptag/0x3613001E" Value = "IPF.NOTE" Set oOutlook = CreateObject("Outlook.Application") Set oFolder = oOutlook.ActiveExplorer.CurrentFolder Set oPA = oFolder.PropertyAccessor FolderType = oPA.GetProperty(PropName) 'MsgBox (FolderType) If FolderType = "IPF.Imap" Then oPA.SetProperty PropName, Value End If
PowerShell to change folder type
To use this PowerShell, select the root folder in the PST file, usually named Outlook Data File and run the code. Because this script lists the folders and the folder type, you can run the script a second time on the folders to verify they changed to IPF.Note.
If you only have one or two errors (red text as seen in my screenshot below), they can be ignored, in my tests, its generated on the Outbox and Deleted Items folders
Note: In my tests, the view on a few folders didn't change until after I restarted Outlook, even though the folder type changed.
clear $Outlook = New-Object -comobject Outlook.Application $ns = $Outlook.GetNameSpace("MAPI") $PropName = "http://schemas.microsoft.com/mapi/proptag/0x3613001E" $oFolder = ($Outlook.ActiveExplorer()).CurrentFolder ListFolders $oFolder.Folders "" Function Listfolders { param($Folders, $Indent) ForEach ($Folder in $Folders | sort-object name) { $oPA = $Folder.PropertyAccessor $value = $oPA.GetProperty($PropName) write-host $Indent$($Folder.Name)" ("$($Folder.Items.Count)")" $value If ($value -eq 'IPF.Imap') { $oPA.SetProperty($PropName, 'IPF.Note') } Listfolders $Folder.Folders $Indent" " } }
Using PowerShell Scripts
To use PowerShell scripts with Outlook, start typing powershell on the start menu and open Windows PowerShell when it comes up. Windows PowerShell ISE has a script pane at the top, which is useful if you want to edit the script.
Paste the entire script in the PowerShell window and press Enter or the Run button if using PowerShell ISE.
Note: PowerShell scripts will not work with the Windows Store version of Office. You'll need to use a VBA macro version if you have the Windows store version of Office installed.
Saving PowerShell Scripts
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.
VBA macros to change folder type
Option Explicit Public Sub ChangeFolderContainer() Dim oFolder As Outlook.folder Dim oPA As Outlook.PropertyAccessor Dim PropName, Value, FolderType As String PropName = "http://schemas.microsoft.com/mapi/proptag/0x3613001E" Value = "IPF.Note" Set oFolder = Application.ActiveExplorer.CurrentFolder Set oPA = oFolder.PropertyAccessor FolderType = oPA.GetProperty(PropName) 'MsgBox (FolderType) If FolderType = "IPF.Imap" Then oPA.SetProperty PropName, Value End If Set oFolder = Nothing Set oPA = Nothing End Sub
Change Subfolders
This version of the macro above will walk the folder list and change all folders from IPF.Imap to IPF.Note. This uses the folder picker and you can choose the root folder (top of mailbox) to run it on all folders in your mailbox or a parent folder to run it only on that folder and it's subfolders.
Option Explicit Dim SubFolder As MAPIFolder Sub ChangeFolderClassAllSubFolders() Dim i As Long Dim iNameSpace As NameSpace Dim myOlApp As Outlook.Application Dim ChosenFolder As Object Dim Folders As New Collection Dim EntryID As New Collection Dim StoreID As New Collection Set myOlApp = Outlook.Application Set iNameSpace = myOlApp.GetNamespace("MAPI") Set ChosenFolder = iNameSpace.PickFolder If ChosenFolder Is Nothing Then GoTo ExitSub: End If Call GetFolder(Folders, EntryID, StoreID, ChosenFolder) ChangeFolderContainer For i = 1 To Folders.Count Set SubFolder = myOlApp.Session.GetFolderFromID(EntryID(i), StoreID(i)) On Error Resume Next ChangeFolderContainer On Error GoTo 0 Next i ExitSub: End Sub Private Sub ChangeFolderContainer() Dim oFolder As Outlook.folder Dim oPA As Outlook.PropertyAccessor Dim PropName, Value, folderType As String PropName = "http://schemas.microsoft.com/mapi/proptag/0x3613001E" Value = "IPF.Note" On Error Resume Next Set oFolder = SubFolder 'Application.ActiveExplorer.CurrentFolder Set oPA = oFolder.PropertyAccessor folderType = oPA.GetProperty(PropName) Debug.Print SubFolder.Name & " " & (folderType) If folderType = "IPF.Imap" Then oPA.SetProperty PropName, Value Debug.Print " Changed: " & SubFolder.Name & " " & Value End If Set oFolder = Nothing Set oPA = Nothing End Sub Sub GetFolder(Folders As Collection, EntryID As Collection, StoreID As Collection, Fld As MAPIFolder) Dim SubFolder As MAPIFolder Folders.Add Fld.FolderPath EntryID.Add Fld.EntryID StoreID.Add Fld.StoreID For Each SubFolder In Fld.Folders GetFolder Folders, EntryID, StoreID, SubFolder Next SubFolder ExitSub: Set SubFolder = Nothing End Sub
How to use macros
First: You will need macro security set to low during testing.
To check your macro security in Outlook 2010 or 2013, 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.
After you test the macro and see that it works, you can either leave macro security set to low or sign the macro.
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
Thank you a million times over! I recently had to move my email from an existing RSP who have decided to not provide email services any longer, over to Outlook 365 (bascially down to familiar functionality and email address availability).
Your Powershell Script has allowed me to avoid rebuilding 20 years of email history! All of course visible in OWA, but that's less than ideal to use.
The PS Script was easy, and now I have full access again to all of my folders in the Outook client.
Thankyou Thankyou Thankyou!
Thank you this was a a life saver!! I was getting ready to rebuild 50 Folders from Scratch.
Can you help with this please:
Compile error, Variable not defined (amp;)
Hi Ivan,
I have the same error message. Did you find a solution for it?
Thank you. It helped to sort the issue.
Thank you - a life saver!!
Hi - When I try to run this macro I get a runtime error stating
The property "http://schemas.microsoft.com/mapi/proptag/0x39FE001E" is unknown or cannot be found.
Could someone help with this problem?
Diane, thank you for this. MS Support sent me round in circles, this script has saved me a huge amount of time. Cheers.
Amazing! That automated macro on what must be 90 folders, was a god send! Thank you!! I think this needs to be more publicly available!