Email Trace Listener Not Sending Emails - In Code, Works

Topics: Exception Handling Application Block, Logging Application Block
Feb 17, 2010 at 9:56 PM

Hi, I have set up a email trace listener reference with all the properties and dependencies correct. In this code:

protected void Page_Load(object sender, EventArgs e)
{
    Exception exception = new Exception("Test 2");

    ExceptionPolicy.HandleException(exception, "Exception Policy");

    this.SendMail();
}

private void SendMail()
{
    Server.ScriptTimeout = 1000;
    Response.Flush();
    MailMessage message = new MailMessage("to@acompany.org.au", "from@cplqld.org.au", "Test", "Test...");
    SmtpClient emailClient = new SmtpClient("mail.acompany.com", 25);

    try
    {
        emailClient.Send(message);

        Response.Write("The Mail has been sent to: ");
        Response.Write(message.To);
    }
    catch (Exception ex)
    {
        Response.Write(ex.Message);
    }

    Response.Flush();
}

The category handling the exception has an email and a database trace listener. The database records the above log event fine but the email is never sent (there is no error or exception reported in the event log regarding sending the email).

The email trace listener uses the same information as the SendMail() method above - SendMail executes fine and the email is received but the email trace listener does not...

What do I do to trace the problem??

Regards,

Richard

 

 

 

 

 

Feb 18, 2010 at 12:48 AM

Did you add the Formatted EventLog Trace Listener under the Logging Errors and Warnings Section? If you had already, do you have the option to configure the properties of your smtp server?

  • Right-Click on My Computer , click Manage
  • Expand the Services and Applications node
  • Expand the Internet Information Services
  • Right-Click on the "Default SMTP Virtual Server" > Properties
  • In the General tab, there is a IP address dropdown. try selecting your local IP address.
  • Go to the Access tab
  • Click the Relay button below.
  • Select the "Only the list below" option
  • Add your IP address on the list
  • Click OK.

    Sarah Urmeneta
    Global Technology and Solutions
    Avanade, Inc.
    entlib.support@avanade.com