Warn before sending emails to external domains in Outlook

后端 未结 3 1446
面向向阳花
面向向阳花 2021-02-03 12:29

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

3条回答
  •  耶瑟儿~
    2021-02-03 12:41

    1. Add the below code to the Application_ItemSend event in Outlook & change the domain to your own

    2. Change the Macro Security to either (Notifcations for all macros or Enable all macros)

    This will provide you with a warning before sending if 1 or more of your TO,CC or BCC address is not in your domain (eg below @mycompany.com.au)

    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
        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)), "@mycompany.com.au") = 0 Then
                If MsgBox("Send mail to external domain?", vbYesNo + vbQuestion + vbMsgBoxSetForeground, "Check Address") = vbNo Then
                    Cancel = True
                    Exit Sub
                Else
                    Exit Sub
                End If
            End If
        Next
    End Sub
    

提交回复
热议问题