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
- At the very outset, launch Outlook VBA editor with reference to “How to Run VBA Code in Your Outlook“.
- 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", "email@example.com") strReplace = InputBox("Specify the email address to replace:", "Replace", "firstname.lastname@example.org") 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 objConditionRecipient.Delete objConditionRecipients.Add strReplace End If Next End If Next '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 objActionRecipient.Delete objActionRecipients.Add strReplace End If Next End If Next 'Save the rule changes objRules.Save Next End If End Sub
- After that, click the “Run” icon in toolbar to trigger this macro.
- Next,specify the email address to be found and the corresponding replacement, like the following screenshot.
- 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.
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.
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 www.datanumen.com