Solved

search and replace special characters in outlook folder names

Posted on 2013-11-04
1
473 Views
Last Modified: 2013-11-14
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
Comment
Question by:Yann Shukor
1 Comment
 
LVL 22

Accepted Solution

by:
rspahitz earned 500 total points
ID: 39623466
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

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Join & Write a Comment

We are happy to announce a brand new addition to our line of acclaimed email signature management products – CodeTwo Email Signatures for Office 365.
This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
In this Experts Exchange video Micro Tutorial, I'm going to show how small business owners who use Google Apps can save money by setting up what is called a catch-all email address in their Gmail accounts. By using the catch-all feature, small busin…
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now