- To post as a guest, your comment is unpublished.· 2 months agoIt works just fine, but there a few things you have to change to get it to work every time you load outlook. Macro security settings need to be changed.
How to get warning when sending email to external domain in Outlook?
While using Outlook, how can you prevent sending emails accidentally to recipients outside your company? Actually, you can display warning box when sending email to external domain in Outlook. This article will introduce a VBA method to achieve it.
- Reuse Anything: Add the most used or complex formulas, charts and anything else to your favorites, and quickly reuse them in the future.
- More than 20 text features: Extract Number from Text String; Extract or Remove Part of Texts; Convert Numbers and Currencies to English Words.
- Merge Tools: Multiple Workbooks and Sheets into One; Merge Multiple Cells/Rows/Columns Without Losing Data; Merge Duplicate Rows and Sum.
- Split Tools: Split Data into Multiple Sheets Based on Value; One Workbook to Multiple Excel, PDF or CSV Files; One Column to Multiple Columns.
- Paste Skipping Hidden/Filtered Rows; Count And Sum by Background Color; Send Personalized Emails to Multiple Recipients in Bulk.
- Super Filter: Create advanced filter schemes and apply to any sheets; Sort by week, day, frequency and more; Filter by bold, formulas, comment...
- More than 300 powerful features; Works with Office 2007-2019 and 365; Supports all languages; Easy deploying in your enterprise or organization.
The following VBA code can help you get warning when sending email to external domain in Outlook. Please do as follows.
1. Press the Alt + F11 keys to open the Microsoft Visual Basic for Applications window.
2. In the Microsoft Visual Basic for Applications window, double click ThisOutlookSession to open the ThisOutlookSession (Code) window, and then copy below VBA code into the window. See screenshot:
VBA code: Get warning when sending email to external domain
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean) 'Update by Extendoffice 20180504 Dim xMailItem As Outlook.MailItem Dim xRecipients As Outlook.Recipients Dim i As Long Dim xRecipientAddress As String Dim xPrompt As String Dim xYesNo As Integer Dim xPos As Integer On Error Resume Next If Item.Class <> olMail Then Exit Sub Set xMailItem = Item Set xRecipients = xMailItem.Recipients For i = xRecipients.Count To 1 Step -1 xRecipientAddress = xRecipients.Item(i).Address xPos = InStrRev(LCase(xRecipientAddress), "@addin99.com") If xPos <= 0 Then Exit For Cancel = False Next If InStrRev(LCase(xRecipientAddress), "@addin99.com") > 0 Then Exit Sub xPrompt = "Are you sure to send this email to outside your company? " xYesNo = MsgBox(xPrompt, vbYesNo + vbQuestion, "Kutools for Outlook") If xYesNo = vbNo Then Cancel = True End Sub
Note: In the code, “@addin99.com” is the internal email domain you will send emails to. Please change it as you need.
From now on, when clicking Send button to send emails to external email domain (not the internal email domain you specified in the VBA code), a warning box will pop up as below screenshot shown.
You are guest
or post as a guest, but your post won't be published automatically.
- To post as a guest, your comment is unpublished.· 11 months agoDoesn't work, no pop-up is showing.
- To post as a guest, your comment is unpublished.· 1 years agoI had the same problem - getting warning also for the internal e-mails.
When the internal e-mail address from Directory is used, xRecipientAddress does not return the address, but some weird exchange string like /O=<organization...> - try to print it in MsgBox and you will see yours.
- To post as a guest, your comment is unpublished.· 1 years agoThis does not work. I do not get a pop up for internal or external.
- To post as a guest, your comment is unpublished.· 1 years agoThis is prompting both internal and external emails. both domain fields have been updated. Any thoughts? Many thanks
- To post as a guest, your comment is unpublished.· 1 years agoHola:
Gran aporte pero me lo pregunta para todos los envíos y no solo para los de una determinada dirección. Es decir, siempre me sale el mensaje independientemente del dominio... ¿está bien el código? Gracias.