IMAP Folder/Subfolders conversion to Post and Mail

Root Folder > Outlook
Some of Your Tech Guys' engineers have met a battle after converting an IMAP account over to an Exchange account where the folders' attributes are kept as IMAP folders while all other folders (and new ones) are Post and Mail.  When this occurs, the IMAP folders can be hidden from OWA and some times Outlook View.  Changing the View helps, but for ActiveSync devices i.e. iPhones, Microsoft and Droids, those folders are not seen.
 
To prevent this from happening, during the conversion process, IT should export directly from the "original" IMAP account of the folder or the entire mailbox out to a PST which will rip out the attribute and convert it to Post/Mail.  If not, importing it back or creating a new IMAP account may not even resolve the issue.  The original export is already needed with the import to move the data into the Exchange account for syncing or into the local POP account.  So, the process is already required.
 
However, when a PST folder is created and the email is manually moved and then imported... and then the account has been used for a few days where new emails are moved around, the process of importing it back or moving emails around can become utterly difficult and will result in manual human error.
 
There is a way to convert a folder and its subfolder from IMAP to POST/MAIL.  In the attribute of the folders and subfolders, they are tagged IPF.IMAP.  The POST/MAIL folders are tagged IPF.NOTE.  The script below will convert the folder and its subfolders to IPF.NOTE.
 
In Outlook 2010/2013/2016 - Disable the Macro Security as this script is a Macro that needs to be ran
Within Outlook, press Alt + F11 to pull up the Visual Studio/Basic macro script to run the script
Inside the Project1 location, paste the following script
 
*** Start of code - do not copy this
 

 
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
 

 
***End of code - do not copy this
 
Select the folder and it will convert it.  Happy converting from IMAP to POST.
 
 

Add Feedback