views:

111

answers:

3

Hey guys, I am trying to add the capability of my Windows Form application being able to send me an e-mail message when my application generates an error message. How do I setup a web service for my application? Any feedback would be greatly appreciated.

+1  A: 
  1. You don't need a Web Service to send emails.
  2. If you really want to use a web service, I would think you would actually create the web service on a server that will listen for message from the client. You could setup the windows form application with a WCF client and setup a WCF server to receive messages, but I think this is overkill.
  3. I personally would use the log4net framework and configure an SmtpAppender to send emails when you log an error. It's really elegant when you get the hang of it.
AaronLS
+1 for log4net and not writing it yourself
smaclell
+1  A: 

You don't need a web service for something like this.

You can use the MailMessage class from the System.Net namespace - the trick is to use the correct SMTP server settings, possibly with the SmtpClient class. This is something you will have to get on your own - from your network admin or ISP.

Oded
+1  A: 

Take a look at the Enterprise Library Exception Handling Application Block.

The Exception Handling Application Block is designed to address the most common tasks developers face when they write applications that use exception handling. These tasks are arranged according to scenarios. Each scenario gives an example of a real-world situation, discusses the exception handling functions the situation requires, and shows the code that accomplishes the task.

The goal of arranging these tasks according to scenarios is to give the code some context. Instead of displaying an isolated group of methods, with no sense of where they can best be used, scenarios provide a setting for the code and describe situations that are familiar to many developers whose applications must handle exceptions.

The scenarios are the following:

  • Logging an Exception
  • Wrapping an Exception
  • Replacing an Exception
  • Propagating an Exception
  • Displaying User-Friendly Messages
  • Notifying the User
  • Assisting Support Staff
  • Shielding Exceptions at WCF Service Boundaries
Michael Valenty