title: How to check sending email address before sending?
body: <p>I use multiple accounts in Outlook. I want to give a warning box if sending from an address I should not be sending from.</p>
  <p>I have two addresses that I should never send from (they are receive only accounts).</p>
  <p>This example is almost what I am looking for.
  <a href="http://www.slipstick.com/how-to-outlook/prevent-sending-messages-to-wrong-email-address/" rel="nofollow noreferrer">Example - Checking the &quot;To&quot; address.</a></p>
  <p>I believe a string comparison (StrComp) and <code>Item.SenderEmailAddress</code> is what I need.</p>
  <p>Here is my attempt for giving a warning for a single email address (bad.email@gmail.com).</p>
  <pre class="lang-vb prettyprint-override"><code>Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
              
  On Error Resume Next
  ' use lower case for the address
  ' LCase converts all addresses in the To field to lower case
  If StrComp((Item.SenderEmailAddress), &quot;bad.email@gmail.com&quot;) Then
      Exit Sub
  End If
      
  Prompt$ = &quot;You sending this from &quot; &amp; Item.SenderEmailAddress &amp; &quot;. Are you sure you want to send it?&quot;
  If MsgBox(Prompt$, vbYesNo + vbQuestion + vbMsgBoxSetForeground, &quot;Check Address&quot;) = vbNo Then
      Cancel = True
  End If
  
  End Sub
  </code></pre>
  <p>Ideally I would to check two or more addresses with the same code. Something like in the example should work.</p>
  <pre class="lang-vb prettyprint-override"><code>Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
  On Error Resume Next
  Select Case LCase(Item.To)
  Case &quot;alias@domain.com&quot;, &quot;alias2@domain3.com&quot;, &quot;alias3@domain3.com&quot;
      Item.Send
  Case Else
      Prompt$ = &quot;You are not sending this to &quot; &amp; Item.To &amp; &quot;. Are you sure you want to send the Mail?&quot;
      If MsgBox(Prompt$, vbYesNo + vbQuestion + vbMsgBoxSetForeground, &quot;Check Address&quot;) = vbNo Then
          Cancel = True
      End If
      
  End Select
      
  End Sub
  </code></pre>
  <p>Also, where do I place the code to ensure that it is constantly running and ready?</p>