Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Warn before sending emails to external domains in Outlook

Tags:

email

vba

outlook

How can you get Outlook to warn you if you are about to send and email to an external domain?

Sending large amounts of emails everyday it is always possible to incorrectly send one to the wrong person. This is especially a problem when they are clients or people outside of your company.

Using Alt + Enter to quickly send emails after typing them for me is often the cause as I do not check the recipients thoroughly.

I have found numerous implementations which were not great so I thought I would share mine below...

like image 873
ojhawkins Avatar asked Jul 20 '13 00:07

ojhawkins


People also ask

How do I set up an external email warning in Outlook?

Click through (1) Mail Flow, (2) Rules, click the (3) + sign, and select (4) Create a new rule. 3. Give your rule a sensible name, such as Flag External Email Warnings. Under the Apply this rule if, choose the sender is located, select Outside the organization, and OK.

How do you add a warning message to the email originating from outside your organization?

Select “The sender is located…”, from the drop-down menu then choose “Outside the organization” from the resulting “select sender location” window: 9. For *Do the following… , select “Apply a disclaimer to the message…” , “append the disclaimer”.

Do external email warnings work?

They notify users that an email comes from outside of an organization or network and should be scrutinized. It is necessary to understand, however, that seeing an email warning tag does not mean an email is malicious. Rather, it warns a user to verify a source and pay attention.


1 Answers

Thanks ojhhawkins for the code above - really useful. I've done a simple iteration to include a list of the external email addresses in the MsgBox text.

Word of caution - I've noticed that the warning doesn't appear when you use the Send As Email Attachment in other programmes, eg Excel, Adobe Reader etc. As niton pointed out:

Re:Send As Email Attachment in other programmes. Described in notes here outlookcode.com/d/code/setsavefolder.htm "... does not work on messages created with File | Send commands in Office programs or similar commands in Windows Explorer or other programs. Those commands invoke Simple MAPI, which bypasses Outlook functionality."

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    Dim recips As Outlook.Recipients
    Dim recip As Outlook.Recipient
    Dim pa As Outlook.PropertyAccessor
    Dim prompt As String
    Dim strMsg As String

    Const PR_SMTP_ADDRESS As String = "http://schemas.microsoft.com/mapi/proptag/0x39FE001E"

    Set recips = Item.Recipients
    For Each recip In recips
        Set pa = recip.PropertyAccessor
        If InStr(LCase(pa.GetProperty(PR_SMTP_ADDRESS)), "@example.com") = 0 Then
            strMsg = strMsg & "   " & pa.GetProperty(PR_SMTP_ADDRESS) & vbNewLine
        End If
    Next

    If strMsg <> "" Then
        prompt = "This email will be sent outside of example.com to:" & vbNewLine & strMsg & "Do you want to proceed?"
        If MsgBox(prompt, vbYesNo + vbExclamation + vbMsgBoxSetForeground, "Check Address") = vbNo Then
            Cancel = True
        End If
    End If
End Sub

To actually add this code to your Outlook application:

  • If you can't see the Developer tab in the ribbon bar, go to File/Options, choose Customise Ribbon on the left, and tick Developer on the right.
  • From the Developer tab choose Visual Basic.
  • Expand Project1, Microsoft Outlook Objects, and double-click ThisOutlookSession (top left).
  • Paste the code above into the module.
  • Replace the "example.com" in the copied code to your domain.
  • Close the VBA editor and save changes to the module.
  • On the Developer tab click Macro Security, and change the level to Notifications for all macros or lower.
  • Restart Outlook. (The code above will not initialise otherwise.)
like image 163
matho Avatar answered Nov 15 '22 19:11

matho