Create a warning confirmation when send out email to certain contacts in Outlook 2010

I made a mistake today that put “everyone@example.com” in CC field, I am glad that I didn’t write anything stupid in it :P, and here is the thought: create a warning/confirmation popup if we’re going to send the email to certain email address.

Here are the instructions:

  1. Configure Outlook 2010 be able to run custom macro: navigate to Options -> Trust Center -> Trust Center Settings -> Macro Settings, check “Notifications for all macros”, then click OK and restart your outlook
    Configure outlook macro settings
  2. Click “Alt+F11” (or Navigate to the Developer Panel -> “Visual Basic”), expand the project and double click on “ThisOutlookSession” and paste the following code at the right side panel, modify the “everyone@example.com” to your own settings:

    Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
      Dim strMsg As String
        If Item.To = "everyone@example.com" Or Item.CC = "everyone@example.com" Or Item.BCC = "everyone@example.com" Then
        strMsg = "You're sending this email to EVERYONE!!!" & vbCrLf & vbCrLf & _
        "To: " & Item.To & vbCrLf & "Cc: " & Item.CC & vbCrLf & "Bcc: " & Item.BCC & vbCrLf & vbCrLf & _
        "Are you sure you want to send this message?"
        If MsgBox(strMsg, vbYesNo + vbExclamation + vbDefaultButton2, "SEND CONFIRMATION") = vbNo Then
          Cancel = True
        End If
      End If
    End Sub
    
  3. Save the code and restart the outlook, and when you send to everyone next time, it will popup a confirmation window like this:

Be careful when you debugging, it might actually send out the email to everyone! 😛