[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 572
  • Last Modified:

search and replace special characters in outlook folder names

Hi

I encourage my clients as much as I can to upgrade to online IMAP accounts

I often in the process have to transfer large quantities of data in the form of client emails
up to their new accounts

Forward slashes and periods wreak havoc during the transfer process, and slow everything down when one has to stop to analyze and determine what is still left to be uploaded

But some client folder structures are so immense that I could spend weeks sifting through them and still miss one of these troublesome characters.

Is there a way to automate the replacement of these characters throughout a PST or folder structure ? An Outlook macro maybe ?

any ideas ?

thanks

yann
0
Yann Shukor
Asked:
Yann Shukor
1 Solution
 
rspahitzCommented:
You can try something like this:
Private Sub ShowAccountFolders()
    Dim pstFolders As Folders
    Dim objFolder As MAPIFolder
    Dim pstExplorers As Explorers
    Dim pstExplorer As Explorer
    Dim obj As Object
    Dim iExplorerCntr As Integer
    Dim iFolderCntr As Integer
    
    On Error Resume Next
    
    Set pstExplorers = Outlook.Application.Explorers
    For iExplorerCntr = 1 To pstExplorers.Count
        Set pstExplorer = pstExplorers.Item(iExplorerCntr)
        Set objFolder = pstExplorer.CurrentFolder
            
        Debug.Print objFolder.Name ', objFolder.Views.Count, objFolder.DefaultItemType
        Set pstFolders = objFolder.Folders
        ShowSubFolders pstFolders, 1
        Debug.Print
    Next
    
    Set pstExplorers = Nothing
End Sub

Private Sub ShowSubFolders(FolderObject As Folders, Level As Integer)
    Dim pstFolders As Folders
    Dim iFolderCntr As Integer
    Dim strIndent As String
    
    strIndent = String(Level, vbTab)
    For iFolderCntr = 1 To FolderObject.Count
        Debug.Print strIndent; FolderObject(iFolderCntr).Name
        
        If FolderObject(iFolderCntr).Folders.Count > 0 Then
            ShowSubFolders FolderObject(iFolderCntr).Folders, Level + 1
        End If
        
        FolderObject(iFolderCntr).Name = UpdateName(FolderObject(iFolderCntr).Name)
    Next
End Sub

Private Function UpdateName(StartingName As String) As String
    Dim strNewName As String
    
    strNewName = StartingName ' apply filtering of characters, etc.
    UpdateName = strNewName
End Function
    

Open in new window


You will need to:
1) Enable macros in Outlook
2) Click on the top-level folder ("Personal Folders")
3) Update the "UpdateName" routine to handle any of the adjustments you need, such as removing any apostrophes, replacing double-quotes with single quotes, etc.
0

Featured Post

Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

Tackle projects and never again get stuck behind a technical roadblock.
Join Now