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
- For a start, launch Outlook application.
- Then, enter VBA editor window via the shortcut “Alt + F11”.
- 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
- After that, in accordance to “How to Run VBA Code in Your Outlook“, add this macro to Quick Access Toolbar or ribbon.
- Subsequently, exit the VBA editor normally.
- 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.
- 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.
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
Leave a Reply