views:

810

answers:

1

I like the MS Enterprise Library Logging Application Block because it lets me easily define a few logging settings and then log an error in a line or so of code from my application.

However, I really want to be able to send email using my SMTP server's pickup folder (as opposed to specifying the servername and port). Just using the plain old System.Net block in your web.config, you could do:

<system.net>
    <mailSettings>
        <smtp deliveryMethod="pickupDirectoryFromIis" from="[email protected]">
        </smtp>
    </mailSettings>
</system.net>

or something like that, and then you're done.

Is this possible in the Logging Application Block? I don't want to specify the server and port.

Thanks, Stack Overflow!

A: 

If you want to email warnings:

Add a warning category.

Create a Trace Listener to allow us to send warnings to an email address: Right click the Trace Listeners and add a new Email Trace Listener. Set all the parameters, they’re pretty straight forward. Right click your Warning category and add a new trace listener referencing reference your email trace listener.

Logger.Write("Warning Message", "Warning", 1, 1,
             System.Diagnostics.TraceEventType.Warning);

Ref: Microsoft Enterprise Library #1 – Logging Application Block

Mitch Wheat
@Mitch Wheat, thanks for the tip, but actually I'm not just trying to create a trace listener. I'm specifically trying to send email using the SMTP Pickup Folder as opposed to using an SMTP Server and Port. The reason here is that the SMTP server is the same as the webserver and using the local pickup folder is a very easy and efficient way to send mail.Any idea how to do this in the Logging Application Block, or do I need to customize some of their code?Thanks!
Pandincus