How to Quickly Create an Outlook Rule to Block the Senders of Multiple Emails

If you want to create a rule to block the senders of multiple selected emails, usually, you have to first write down the senders and then create a rule manually. It is quite troublesome. Thus, here we will share a much quicker method to get it via one click.

Some users think the inbuilt “ant-spam” feature in Outlook is not as effective as they hope. Therefore, they are accustomed to creating Outlook rules to block the senders. Now, in the followings, we will introduce a quick method to create a rule to block the senders of multiple emails.

Quickly Create a Rule to Block Senders of Multiple Emails

  1. For a start, launch Outlook application.
  2. Then, enter VBA editor window via the shortcut “Alt + F11”.
  3. Next, in the new window, put the following VBA code into an unused module.
Sub CreateRuleForBlockingMultipleSenders()
    Dim objRules As Outlook.Rules
    Dim objRule As Outlook.Rule
    Dim objMoveRuleAction As Outlook.MoveOrCopyRuleAction
    Dim objFromCondition As Outlook.ToOrFromRuleCondition
    Dim objSelection As Outlook.Selection
    Dim objMail As Outlook.MailItem
    Dim objJunkFolder As Outlook.Folder
 
    Set objRules = Application.Session.DefaultStore.GetRules()
    'Create a rule
    Set objRule = objRules.Create("Block Senders", olRuleReceive)
    Set objFromCondition = objRule.Conditions.From
 
    'Get the selected emails
    Set objSelection = Outlook.Application.ActiveExplorer.Selection
    'Get Junk Email folder
    Set objJunkFolder = Outlook.Application.Session.GetDefaultFolder(olFolderJunk)
 
    For i = objSelection.Count To 1 Step -1
        If objSelection.Item(i).Class = olMail Then
 
           Set objMail = objSelection.Item(i)
 
           'Add the email senders to rule condition
           With objFromCondition
                .Enabled = True
                .Recipients.Add objMail.SenderEmailAddress
                .Recipients.ResolveAll
           End With
 
           'Move the emails from blocked senders to Junk Email folder
           Set objMoveRuleAction = objRule.Actions.MoveToFolder
           With objMoveRuleAction
                .Enabled = True
                .Folder = objJunkFolder
           End With
         End If
    Next
 
    objRules.Save
End Sub

VBA Code - Quickly Create a Rule to Block the Senders of Multiple Emails

  1. After that, in accordance to “How to Run VBA Code in Your Outlook“, add this macro to Quick Access Toolbar or ribbon.
  2. Subsequently, exit the VBA editor normally.
  3. Lastly, take the following steps to have a try.
  • First of all, select the emails whose senders you want to block.
  • Then, click the new macro button.Run Macro on Selected Emails
  • After macro finishes, you can go to “File” menu and click “Manage Rules and Alerts” button to check the newly added rule, as shown in the image below.New Rule

Keep Malicious Emails at Bay

No matter what email client you use, you must frequently receive the emails from unknown senders. Most of the emails may be advertising spams and even contain malicious macros. They can damage your Outlook file in a jiffy. Thus, in Outlook, you ought to take effective measures to block the unknown emails. In addition, if you can afford it, it is advisable to prepare a powerful PST recovery tool, such as DataNumen Outlook Repair. It can repair Outlook file without breaking a sweat no matter how seriously it’s damaged.

Author Introduction:

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

2 responses to “How to Quickly Create an Outlook Rule to Block the Senders of Multiple Emails”

  1. How do you edit this VBA script to “update” the existing BLOCK SENDERS list instead of creating a separate rule each time you run the script?

Leave a Reply

Your email address will not be published. Required fields are marked *