Solved

Error Reporting

Posted on 2006-11-07
3
391 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of convertingā€¦
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that undeā€¦

738 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