How to Batch Replace One Email Address with Another in All Outlook Rules

If you want to search all rules to find and replace a specific email address with the other address, you can read this article. Here we will teach you how to get it with no needs to check and change your rules one by one manually.

Outlook rule is a quite convenient and excellent feature, which can automate lots of your desired tasks. Thus, maybe you’ve created multiple rules in your Outlook. In face of so many rules, you’ll encounter a trouble – a bit difficult to search and manage the rules. For instance, a specific contact’s email address is modified. So, you’d like to check every rule to find the contact’s email address and change it to a new email address. In this case, if you have a great amount of rules, it’ll be too tedious to check and change rules one by one. Therefore, here we will introduce a much smarter way to you.

Batch Replace One Email Address with Another in All Rules

  1. At the very outset, launch Outlook VBA editor with reference to “How to Run VBA Code in Your Outlook“.
  2. Then, put the following VBA code into a blank module.
Sub BatchChangeEmailAddressesinRules()
    Dim strFind, strReplace As String
    Dim objRules As Outlook.Rules
    Dim i As Long
    Dim objRule As Outlook.Rule
    Dim objRuleCondition As Outlook.RuleCondition
    Dim objToFromCondition As Outlook.ToOrFromRuleCondition
    Dim objConditionRecipients As Outlook.Recipients
    Dim objConditionRecipient As Outlook.Recipient
    Dim objRuleAction As Outlook.RuleAction
    Dim objSendAction As Outlook.SendRuleAction
    Dim objActionRecipients As Outlook.Recipients
    Dim objActionRecipient As Outlook.Recipient
    'Specify the email address
    strFind = InputBox("Specify the email address to be found:", "Find", "")
    strReplace = InputBox("Specify the email address to replace:", "Replace", "")
    If strFind <> "" And strReplace <> "" Then
       'Process the rules in your default mailbox
       Set objRules = Outlook.Application.Session.DefaultStore.GetRules
       For i = objRules.Count To 1 Step -1
           Set objRule = objRules(i)
           'Replace the email address in rule conditions
           For Each objRuleCondition In objRule.Conditions
               If (objRuleCondition.ConditionType = olConditionFrom) Or (objRuleCondition.ConditionType = olConditionSentTo) Then
                  Set objToFromCondition = objRuleCondition
                  Set objConditionRecipients = objToFromCondition.Recipients
                  For Each objConditionRecipient In objConditionRecipients
                      If (objConditionRecipient.Name = strFind) Or (objConditionRecipient.Address = strFind) Then
                         objConditionRecipients.Add strReplace
                      End If
               End If
          'Replace the email address in rule actions
          For Each objRuleAction In objRule.Actions
              If (objRuleAction.ActionType = olRuleActionCcMessage) Or (objRuleAction.ActionType = olRuleActionForward) Or (objRuleAction.ActionType = olRuleActionForwardAsAttachment) Or (objRuleAction.ActionType = olRuleActionRedirect) Then
                 Set objSendAction = objRuleAction
                 Set objActionRecipients = objSendAction.Recipients
                 For Each objActionRecipient In objActionRecipients
                     If (objActionRecipient.Name = strFind) Or (objActionRecipient.Address = strFind) Then
                        objActionRecipients.Add strReplace
                     End If
             End If
         'Save the rule changes
    End If
End Sub

VBA Code - Batch Replace One Email Address with Another in All Rules

  1. After that, click the “Run” icon in toolbar to trigger this macro.
  2. Next,specify the email address to be found and the corresponding replacement, like the following screenshot.Specify Email Address for Find and Replace
  3. Eventually, after macro finishes, you can check your rules. All the rules which contain the specific email address have been changed, as shown in the image below.Replaced Email Address in Outlook Rules

If Suffer Outlook Errors

A majority of Outlook regular users have been ever subject to annoying errors. For instance, if you frequently shut down Outlook improperly, one day you may receive the error, like inaccessible PST file. It refers to that your Outlook PST file may be corrupt. Then, you have to fix PST, which can be done by the inbox repair tool or a specialized external utility, like DataNumen Outlook Repair.

Author Introduction:

Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including fix sql and outlook repair software products. For more information visit