title: ELMAH: Only sending specific exception type via mail
body: <p>I have ELMAH set up for a webapp, logging exceptions to a SQL server. </p>
  
  <p>I wish to have ELMAH send me an email too, but only when a specific exception is thrown (ie. <em>MySpecialException</em>).</p>
  
  <p>ELMAH must still log all exceptions to SQL server.</p>
  
  <p>I know you can do it programmatically in global.asax, but I'd prefer to use web.config.</p>
  
  <p>So, how do I restrict ELMAH error mails to filter out everything but a specific exception type, using web.config?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>The filter ended up looking like this:</p>
  
  <pre><code>&lt;test&gt;
      &lt;and&gt;
          &lt;not&gt;
              &lt;is-type binding="Exception" type="MyApp.MySpecialException" /&gt;
          &lt;/not&gt;
          &lt;regex binding="FilterSourceType.Name" pattern="mail" caseSensitive="false"/&gt;
      &lt;/and&gt;
  &lt;/test&gt;
  </code></pre>