Many users hope to block accidentally sending emails to a specific email address in Outlook. Thus, in this article, we will introduce a method to realize it.
Outlook doesn’t provide native features for blocking sending emails to a specific email address. Hence, if you would like to realize it, a bit of scripting is required. Now, in the followings, we’ll share such a piece of VBA code. If you do not know how to use VBA, you can read the previous post – “How to Run VBA Code in Your Outlook“.
Prevent Sending Emails to a Specific Email Address
- At first, access Outlook VBA editor via “Alt + F11”.
- Then, put the following code into the “ThisOutlookSession” project.
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean) Dim objMail As Outlook.MailItem Dim objRecipients As Outlook.Recipients Dim ContactGroupFound As Boolean Dim i, n As Long Dim objRecipient As Outlook.Recipient If TypeOf Item Is MailItem Then Set objMail = Item 'Expand the contact groups in Recipients ContactGroupFound = True Do While ContactGroupFound = True Set objRecipients = objMail.Recipients ContactGroupFound = False For i = objRecipients.Count To 1 Step -1 If objRecipients(i).AddressEntry.DisplayType <> olUser Then For n = 1 To objRecipients(i).AddressEntry.Members.Count If objRecipients(i).AddressEntry.Members.Item(n).DisplayType = olUser Then objMail.Recipients.Add (objRecipients(i).AddressEntry.Members.Item(n).Address) Else objMail.Recipients.Add (objRecipients(i).AddressEntry.Members.Item(n).Name) ContactGroupFound = True End If Next objRecipients(i).Delete End If Next i objRecipients.ResolveAll Loop 'Remove specific email address For Each objRecipient In objRecipients If objRecipient.Address = "shelly@datanumen.com" Then If MsgBox("Do you want to email to " & Chr(34) & "shelly@datanumen.com" & Chr(34) & "?", vbExclamation + vbYesNo) = vbNo Then objRecipient.Delete End If End If Next End If End Sub
- After that, exit the “Microsoft Visual Basic for Applications” window.
- Eventually, try it by the following steps.
- To begin with, compose an email and fill in the recipients.
- Then, click “Send” button.
- At once, the macro will work to expand the contact groups in recipients if there are and find out if recipients contain the specific email address.
- If the address is found, you will get a message, as shown in the following figure.
- If you select “No”, the specific email address will be deleted immediately.
- After the mail is sent, you can check its recipients, which definitely don’t contain the specific email address.
Repair Your Corrupt Outlook File
Have your Outlook file ever been damaged? That is admittedly the most annoying problems in Outlook. When being subject to it, you have to manipulate PST repair, which is a bit knotty. As usual, you will think about using Scanpst in the first time. But, unfortunately, it may fail in such cases. Your resort should be either a more experienced tool, like DataNumen Outlook Repair, or professional PST recovery service.
Author Introduction:
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