Solved

Error Reporting

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Visual Studio .Net 2012 and Crystal Reports 9 64
Run a batch file when a Crystal Report is opened 5 27
vb.net help 4 29
VB.Net - Get ColumnNames of SQL Table 4 10
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…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

785 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