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.
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.
Below are two macros, the first macro changes the only 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 then the one you changed to refresh the folder.)
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
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!
Thank you very much
I must to change more than 150 folders and your macro was perfect
a french boy
Hello Diane,
I had to change from Imap to Exchange due to provider issues and couldn't see subfolders (which are many), some contacts and some dates on my mobile devices.
After I used 2nd VBA Makro all mobile devices (Android, iOs) show the subfolder. all with property "IPM.Post".
Dates are no longer visible on either mobile device.
Is there a comparable solution for this issue.
Thanks a lot for your valuable work.
CNS
Awesome - only word for it!
Legend you. Microsoft support said sorry just deal with it but the client was up my back to get is sorted.
Thanks you.
Thank you Diane, this was just what I needed. I have users with Outlook connecting to a WHM/cPanel mail server moving to office 365. Frustratingly the exported .pst files when imported into Office 365 Exchange had this problem. The macro saved so much time. It just took me ages to find your useful code here in the fist place as I had been searching for "Outlook imported email hidden in folder" not realising it was because the folder type was part of the import. It is a shame there are not more useful links to here on Microsoft's site for people migrating to Office 365
How many times in the past few years this website helped me? I can´t counter it! For my needs, your explanation about what was happening was enough and so on Outlook 2016, on the folder with no mail, I went into the "filter applied" sign, clicked, advanced and removed the status imap filter.
Thank you again for your beautiful work!