Note: The other languages of the website are Google-translated. Back to English

How to block outgoing emails to a specific address in Outlook?

Generally speaking, Outlook sends emails to all normal email addresses, and can’t block sending emails to a specific email address. But, sometimes, you may need to prevent sending emails to a specific email address in Outlook. In this case, this tutorial will introduce a VBA code for solving this task.

Block outgoing emails to a specific address with VBA code

The following VBA code can do you a favor, please do as this:

1. Launch the Outlook, then, hold down ALT + F11 keys to open the Microsoft Visual Basic for Applications window.

2. Then, double click ThisOutlookSession from the Project-Project1 pane, and then, copy and paste the below code into the blank code window:

VBA code: Block outgoing emails to a specific address

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
'Updatby ExtendOffice
Dim xMail As Outlook.MailItem
Dim xRecipients As Outlook.Recipients
Dim xContactGroupFound As Boolean
Dim i, n As Long
Dim xRecipient As Outlook.Recipient
Dim xAddress As String
Const PR_SMTP_ADDRESS As String = ""
On Error Resume Next
If Item.Class <> olMail Then Exit Sub
Set xMail = Item
xContactGroupFound = True
Do While xContactGroupFound = True
  Set xRecipients = xMail.Recipients
  xContactGroupFound = False
  For i = xRecipients.Count To 1 Step -1
    If xRecipients(i).AddressEntry.DisplayType <> olUser Then
      For n = 1 To xRecipients(i).AddressEntry.Members.Count
        If xRecipients(i).AddressEntry.Members.Item(n).DisplayType = olUser Then
          xMail.Recipients.Add (xRecipients(i).AddressEntry.Members.Item(n).Address)
          xMail.Recipients.Add (xRecipients(i).AddressEntry.Members.Item(n).Name)
          xContactGroupFound = True
        End If
    End If
  Next i
For Each xRecipient In xRecipients
  xAddress = xRecipient.PropertyAccessor.GetProperty(PR_SMTP_ADDRESS)
  If VBA.Trim(xAddress) = "" Then
    xAddress = xRecipient.Address
  End If
  If xAddress = "" Then    'change this email address to your need
    If MsgBox("Do you want to email to " & Chr(34) & xAddress & Chr(34) & "?", vbExclamation + vbYesNo, "Kutools for Outlook") = vbNo Then
    End If
  End If
If xMail.Recipients.Count = 0 Then
  Cancel = True
End If
End Sub
Note: In the above code, you should change the email address to your own.

3. Then, save and close this code window. Now, when sending an email, if the specific email address is found in the recipient list, a prompt message will pop out as below screenshot shown. Click No, the specific email address will be deleted immediately.

4. After sending the email, you can check its recipients in the Sent Items folder, the certain email address has been excluded from the recipients, see screenshot:

Kutools for Outlook - Brings 100 Advanced Features to Outlook, and Make Work Much Easier!

  • Auto CC/BCC by rules when sending email; Auto Forward Multiple Emails by custom; Auto Reply without exchange server, and more automatic features...
  • BCC Warning - show message when you try to reply all if your mail address is in the BCC list; Remind When Missing Attachments, and more remind features...
  • Reply (All) With All Attachments in the mail conversation; Reply Many Emails in seconds; Auto Add Greeting when reply; Add Date into subject...
  • Attachment Tools: Manage All Attachments in All Mails, Auto Detach, Compress All, Rename All, Save All... Quick Report, Count Selected Mails...
  • Powerful Junk Emails by custom; Remove Duplicate Mails and Contacts... Enable you to do smarter, faster and better in Outlook.
shot kutools outlook kutools tab 1180x121
shot kutools outlook kutools plus tab 1180x121
Comments (0)
No ratings yet. Be the first to rate!
There are no comments posted here yet
Leave your comments
Posting as Guest
Rate this post:
0   Characters
Suggested Locations