title: How do I email errors logged with NLog?
body: <p>I am using NLog for the first time, i figured out how to write to a text file, but now i want to send an email to myself.  am making the assumption that when you supply SMTP credentials to NLog. The assembly calls the System.Net.Mail namespace and handles sending an email. If this is wrong please tell me. And if you have done this before i would appreciate any information on what it took you to accomplish send emails. </p>
  
  <p>Below is my configuration.</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" &gt;
    &lt;targets&gt;
      &lt;!--&lt;target name="logfile" xsi:type="File" fileName="C:\Users\keithb\Desktop\TestLog.txt" /&gt;--&gt;
      &lt;target name="Mail" xsi:type="Mail" html="true" subject="Error Received" body="${message}"         
           to="user2@someemaill.com"
           from="user@someemail.com"
           Encoding="UTF8"
           smtpUsername="user@someemail.com"
           enableSsl="False"
           smtpPassword="pa$$word"
           smtpAuthentication="Basic"
           smtpServer="mail.someemail.com"
           smtpPort="25" /&gt;
    &lt;/targets&gt;
    &lt;rules&gt;
      &lt;!--&lt;logger name="*" minlevel="Debug" writeTo="logfile" /&gt;--&gt;
      &lt;logger name="*" level="Error" writeTo="Mail" /&gt;
      &lt;logger name="*" level="Fatal" writeTo="Mail" /&gt;
    &lt;/rules&gt;
  &lt;/nlog&gt;
  </code></pre>
  
  <p>I call the error like so</p>
  
  <pre><code>Imports NLog
  
  Public Class HandleGetRouteInfo
      Private Shared logger As Logger = LogManager.GetCurrentClassLogger()
  
      Public Shared Function GetRouteInfo(ByVal routeInfo As RequestGetRouteInfo) As GetRouteInfoResponse
          'TODO: Check route ID, username, password
          logger.Fatal("User" &amp; routeInfo.UserName &amp; "has entered the GetRouteInfo Method.")
          logger.Error("User" &amp; routeInfo.UserName &amp; "has entered the GetRouteInfo Method.")
          Dim str As String = logger.Name
  End Function
  End Class
  </code></pre>
  
  <p>I am trying to get it to send the error, containing message, and the things it normally logs to a file, to my email. I know how to catch exceptions and email it to myself, but i thought NLog had the capabilities to do this. Any tutorials with dead simple examples of using email functionality would work. I found a lot of things but cant get it to work. If you have done this, some sample code or explanation of what else i need to do would help. I cant figure out what it is i am doing wrong. Anyone have any ideas?</p>