After importing IMAP folders into Exchange mailboxes, Outlook keeps the folder format as IMAP meaning that mail isn’t visible.
Once the folder’s class is changed and you refresh the folder, the Views available are the normal folder views. The macro code below uses a folder picker to select the root folder and then change it and its subfolders to the normal non-IMAP type.
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
Open VBA Editor with Alt+F11. Right-click on Project1 and select Insert > Module. Paste the macro code above into the module and then select “Run”