Imports System.Drawing.Imaging Imports System.IO Imports System.Net.Mail Module modErrorHandling Public Sub DisplayErrorMessage(ByVal ex As System.Exception, ByVal Title As String, _ ByVal Subtitle As String, Optional ByVal ExtraMsg As String = "") Windows.Forms.Cursor.Show() Windows.Forms.Cursor.Current = Cursors.Default If ExtraMsg <> "" Then MsgBox(ex.Message, MsgBoxStyle.Information, _ String.Concat("Error occured in ", Title, " - ", Subtitle)) Else MsgBox(String.Concat(ex.Message, vbCrLf, vbCrLf, ExtraMsg), MsgBoxStyle.Information, _ String.Concat("Error occured in ", Title, " - ", Subtitle)) End If WriteEventLog(String.Concat("Error occured in ", Title, " - ", Subtitle, vbCrLf, vbCrLf, _ ex.Message, vbCrLf, vbCrLf, ExtraMsg)) End Sub Private Sub SendErrorEmail(ByVal MsgBody As String) Try Dim msg As New MailMessage With msg .IsBodyHtml = True .Body = MsgBody .From = New MailAddress("pdfutils@stf.com", "PDF Utils") .Subject = "PDF Utils Error on " & My.Computer.Name .To.Add("mmonica@stf.com") Dim smtpMsg As New SmtpClient(My.Settings.SmtpServer) smtpMsg.UseDefaultCredentials = False smtpMsg.Send(msg) TempFileCleanup() End With Catch ex As System.Net.Mail.SmtpException End Try End Sub Private Sub WriteEventLog(ByVal Msg As String) Try Dim dcLog As EventLog = New EventLog() dcLog.Source = My.Application.Info.ProductName dcLog.WriteEntry(Msg, EventLogEntryType.Error) dcLog.Close() SendErrorEmail(Msg) Catch ex As Exception End Try End Sub End Module