Error Handling That Sends Email

Another interesting way to track the errors that are occurring in an application is to add code to the error handling routines that "phone home" when an error occurs. Specifically, the application will build and send an e-mail to you (the developer) whenever an unexpected error occurs. This is usually done with the SendObject method, although there are other ways to utilize MAPI (mail application programming interface) directly.

This approach has the same problems listed in the previous section (Error Handling with Logging), and also has a few more:

□ Your code needs to be able to send an e-mail using an installed e-mail client. There is always a possibility that there is no e-mail client installed, or it is not compatible with your e-mailing code.

□ Some e-mail clients (for example, Microsoft Outlook) have code to protect against viruses using the e-mail program to propagate themselves to other computers. If an outside program (in this case, yours) tries to send an e-mail, a warning message will display alerting the user that a virus may be attempting to send e-mail. This isn't what you want your user to see when your application is running.

As with error handling with logging, this technique to automatically send e-mail when your application encounters an unexpected error is probably more trouble than it is worth.

0 0

Post a comment