Solved

Error Reporting

Posted on 2006-11-07
3
394 Views
Last Modified: 2012-08-13
Instead of a VB.NET WIndows Application error occuring when something like a SQL Query is messed up or something or anyting at that matter that a standard user would have no clue what it means, can I have a custom error display, and then it send an email or something with the workstation or username that it errored out on to am SMTP address?  I have a HUGE application that many custom arguments are used against, and half the time my users never tell me if something is wrong or not, hence, I have no way of tracking things.

I could probably get the SMTP to work, but I need to know if this option is availabe on Windows Applications.  I know I can do it with a web application quite simply!!!

Thanks,
CR
0
Comment
Question by:chrisryhal
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 10

Expert Comment

by:gangwisch
ID: 17892570
they have a control called the errorprovider to where you can validate your exceptions and a red exclamation point will show up if an error exists.
0
 
LVL 14

Accepted Solution

by:
ptakja earned 500 total points
ID: 17895324
This is for Visual Studio 2005...

Include System.Net above your class declaration


        Dim msg As New Mail.MailMessage                                                    'Create new Message object

        'Build list of recipients (on my app, the TO textbox can contain a list of email addresses separated by ";"
        Dim recipients As String() = txtTo.Text.Split(CChar(";"))                      

        ' Configure the message object
        With msg
            .Subject = txtSubject.Text                                                                    'Subject field
            .Body = txtBody.Text                                                                              'Body

            ' Loop through recipients array adding recipients to the message.
            For ii As Integer = 0 To recipients.Length - 1
                .To.Add(New Mail.MailAddress(recipients(ii)))
            Next
            .Sender = New Mail.MailAddress("SenderAddres@YourDomain.com")         'Sender
            .Priority = Mail.MailPriority.Normal                                                           'Normal priority
            .From = .Sender                                                                                    'Set From address = to Sender

        End With

        ' Create new SMTPClient object, add the event handler for the SendCompleted and send the message.
        SMTPClient = New Mail.SmtpClient("YourSMTPServerAddress.com")

' Add handler for SendCompleted Async event. I use this event play a sound after the email has been sent.
        AddHandler SMTPClient.SendCompleted, AddressOf OnSendCompleted
        SMTPClient.SendAsync(msg, 1)



Here's the OnSendCompleted method referenced above to play the sound.

    ''' <summary>
    ''' Event handler for the SendComplete event. Plays the Send Mail system sound when the message has been sent.
    ''' </summary>
    ''' <param name="sender">Not used.</param>
    ''' <param name="e">Not used.</param>
    Private Sub OnSendCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs)

        Dim ms As System.IO.UnmanagedMemoryStream = My.Resources.Send   'Get a Memory Stream from my resources.
        Dim snd As New System.Media.SoundPlayer(ms)                     'Instantiate a SoundPlayer object
        Call snd.Play()                                                 'Play the sound

        ' Cleanup
        Call snd.Dispose()
        Call ms.Dispose()
        Me.Close()                                                      'Close the form
    End Sub
0
 
LVL 2

Author Comment

by:chrisryhal
ID: 17982295
AWESOME solution ptakja

I had to do some modification of course to tailor it what I wanted it to do, but your example worked nicely

Always appreciated!!!

CR
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question