It is easy to find and replace one text with another in email. But, if you would like to batch replace different text with same text, it is suggested to use the method in this article, which can let you achieve it in bulk.
As we all know, Outlook email uses Text editor. Thus, when it comes to finding and replacing something in email, you can just utilize the “Find and Replace” tool, similar to deals in MS Word. However, this feature only supports you to find and replace one text with another at once. If you hope to batch replace many texts with a same text, you can use the following approach.
Batch Replace Different Text with Same One in Email
- At the very outset, launch Outlook program.
- Then, press “Alt + F11” to access VBA editor.
- Next, in the “Microsoft Visual Basic for Applications” window, add reference to “MS Word Object Library” as per “How to Add an Object Library Reference in VBA“.
- After that, put the following code into a blank module.
Sub ReplaceDifferentTextWithSameText() Dim objMail As Outlook.MailItem Dim objMailInspector As Outlook.Inspector Dim objMailDocument As Word.Document Dim strFind, strReplacement As String Dim varFindArray As Variant Dim objMailDocRange As Word.Range Dim i As Integer Set objMail = Outlook.Application.ActiveInspector.CurrentItem Set objMailInspector = objMail.GetInspector 'Turn email into "Edit" mode objMailInspector.CommandBars.ExecuteMso ("EditMessage") Set objMailDocument = objMailInspector.TextEditor strFind = InputBox("Enter the texts for find, use " & Chr(34) & ";" & Chr(34) & "to connect the texts:", , "test;example;model") If strFind <> "" Then strReplacement = InputBox("Enter the text for replace:", , "sample") If strReplacement <> "" Then varFindArray = Split(strFind, ";") 'Start replace For i = 0 To UBound(varFindArray) Set objMailDocRange = objMailDocument.Range With objMailDocRange.Find .ClearFormatting .Text = varFindArray(i) .Replacement.ClearFormatting .Replacement.Highlight = True .Replacement.Text = strReplacement .Forward = True .Wrap = wdFindContinue .Format = True .MatchCase = False .MatchWholeText = True .MatchWildcards = False .MatchSoundsLike = False .MatchAllTextForms = True .Execute Replace:=wdReplaceAll End With Next End If End If End Sub
- Subsequently, add this macro to Quick Access Toolbar or ribbon of Message window, according to the “Optional Step” in “How to Run VBA Code in Your Outlook“.
- Eventually, you can have a try.
- Firstly, open an email.
- Then, click the macro button.
- Next, you will be required to enter the texts to be found and a specific text for replacement.
- After that, when macro completes, all the texts found will be changed to the specific replacement text, like the screenshot below.
Don’t Be Afraid of Outlook Corruption
When coming across Outlook corruption, generally, most users will get worried. However, if you have made backups for your computer, you can rest easy in that it is considerably simple to recover Outlook data from backups. You can just extract the PST file from the backups without needs to repair the compromised PST file. If you intend to repair it, you can select a powerful enough tool, such as DataNumen Outlook Repair.
Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including sql repair and outlook repair software products. For more information visit www.datanumen.com