Solved

Error Reporting

Posted on 2006-11-07
3
387 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
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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

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…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

821 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