?
Solved

Outlook Email Find and Replace Option

Posted on 2011-04-28
5
Medium Priority
?
201 Views
Last Modified: 2012-05-11
I am looking for a way to search through an entire folder of emails and strip out a string of characters inserted from another application. I have found a couple third party options but they do not allow wildcards.

Example of string I'm trying to strip out of 2000+ emails:
(JXTTTTTID: [38521])

The second part starting with the 3 is unique to each email so that's why I need a wildcare like:
Find: (JXTTTTTID: [3*])
Replace With: <blank>

I've had no luck. Maybe this needs to be scripted somehow.

Thanks in advance,
Dave
0
Comment
Question by:amait
  • 3
  • 2
5 Comments
 
LVL 76

Accepted Solution

by:
David Lee earned 1000 total points
ID: 35498191
Hi, amait.

This should do it.  Follow these instructions to use it.

1.  Start Outlook
2.  Click Tools > Macro > Visual Basic Editor
3.  If not already expanded, expand Microsoft Office Outlook Objects
4.  If not already expanded, expand Modules
5.  Select an existing module (e.g. Module1) by double-clicking on it or create a new module by right-clicking Modules and selecting Insert > Module.
6.  Copy the code from the Code Snippet box and paste it into the right-hand pane of Outlook's VB Editor window
7.  Edit the code as needed.  I included comments wherever something needs to or can change
8.  Click the diskette icon on the toolbar to save the changes
9.  Close the VB Editor
10. Open a folder and select one or more messages to process
11. Run the macro to process the selected messages.

Please be sure to try this against a few test items before you put it into production.
Sub amait()
    Dim strResult As String
    For Each olkItm In Application.ActiveExplorer.CurrentFolder.Items
        strResult = SearchAndReplace(olkItm.HTMLBody, "\(JXTTTTTID: \[3\d{1,4}\]\)", "")
        If strResult <> "" Then
            olkItm.HTMLBody = strResult
            olkItm.Save
        End If
    Next
End Sub

Function SearchAndReplace(strItem As String, strSearchText As String, strReplaceText As String) As String
    Dim objRegEx As Object
    Set objRegEx = CreateObject("VBscript.RegExp")
    With objRegEx
        .IgnoreCase = False
        .Pattern = strSearchText
        .Global = True
    End With
    If objRegEx.Test(strItem) Then
        SearchAndReplace = objRegEx.Replace(strItem, strReplaceText)
    Else
        SearchAndReplace = ""
    End If
    Set objRegEx = Nothing
End Function

Open in new window

0
 

Author Comment

by:amait
ID: 35507235
Thank you so much for your time BlueDevilFan. We began writing a script but I will try what you have here and get back to you.

Thanks again for everything. I will award points shortly.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 35507576
Hi, Dave.

I'm a little confused.  If the solution worked, then why are you closing the question by accepting your comment and not giving any points?
0
 

Author Comment

by:amait
ID: 35507616
I intended to award all points to BlueDevilFan but made a mistake.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 35507631
No problem.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to import Lotus Notes Contacts into Outlook 2016, 2013, 2010 and 2007 etc. with a few manual steps. You can easily export and migrate Lotus Notes contacts into Microsoft Outlook without having to use any third party tools.
As a matter of fact, Outlook OST files are of much importance in relation to Exchange mailbox. OST files are independent as they are simply copy of data of a user’s mailbox on Exchange Server. Though, if the server’s status is changed or it is dama…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

571 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