cannot send email from global.asax
<p>I'd like to simply get notified for site errors, and I've this straight forward code that does work everywhere in the application except in global.asax!!</p>

<pre><code>void Application_Error(object sender, EventArgs e) 
    {
        UIHelper.SendErrorMessage(Server.GetLastError());
    }
</code></pre>

<p>code in another project:</p>

<pre><code>public static void SendErrorMessage(Exception ex)
        {
            MailMessage errorMessage = new MailMessage();
            errorMessage.From = new MailAddress("xxxxxx@gmail.com", "Site Errors");
            errorMessage.Subject = "Error in sending overseas user";
            errorMessage.CC.Add(new MailAddress("xxxxxxx@gmail.com", "xxxxx")); //test only
            StringBuilder sb = new StringBuilder();
            sb.AppendFormat("Source:{0}\n", ex.Source);
            sb.AppendFormat("Message:{0}\n", ex.Message);
            sb.AppendFormat("Stack Trace:{0}\n", ex.StackTrace);
            sb.AppendFormat("Inner Exception:{0}\n", ex.InnerException == null ? string.Empty : ex.InnerException.Message);
            errorMessage.Body = sb.ToString();
            errorMessage.IsBodyHtml = false;

            var smtp = new SmtpClient();

            try
            {
                smtp.Send(errorMessage);
            }
            catch
            {
            }
        }
</code></pre>

<p>Update: I've wrote logic to write the exception to a file in a folder in my website, and I tried that logic in my dev box and it worked, but it never works in the Host!! this is drives me crazy! Email logic works in my box, file logging works in my box but none of them works in production?! this is really strange... any thoughts?</p>
