Imports System.Net.Mail Public Class cErrorHandler Public Shared Sub ERR(message As String, stack As String, functionName As String, Optional OP As String = "", Optional title As String = "", Optional mailadess As String = "al@verag.ag", Optional recieverMailAdress As String = "", Optional zusatz As String = "") If OP = "" Then OP = VERAG_PROG_ALLGEMEIN.cAllgemein.ERR_OP_GLOBAL ' GLobal gesetzes Errorhandling! (Standart=SHOW) Select Case OP Case ERROR_OP.MAIL sendERRORperMail(title, message, stack, mailadess, zusatz) Case ERROR_OP.SHOW ' MsgBox("Fehler in der Funktion '" & System.Reflection.MethodInfo.GetCurrentMethod.Name & "'" & vbNewLine & vbNewLine & ex.Message) MsgBox(If(functionName <> "", "Fehler in der Funktion '" & functionName & "'" & vbNewLine & vbNewLine, "") & message & vbNewLine & stack & vbNewLine & zusatz, MsgBoxStyle.OkOnly, If(title <> "", title, "Fehler")) End Select End Sub Shared Sub sendERRORperMail(title, errmsg, errstack, recieverMailAdress, zusatz) Dim Msg As New MailMessage Dim myCredentials As New System.Net.NetworkCredential myCredentials.UserName = "support@verag.ag" myCredentials.Password = "support" Msg.IsBodyHtml = False Dim mySmtpsvr As New SmtpClient() mySmtpsvr.Host = "owa.verag.ag" 'bei web.de mySmtpsvr.Port = 25 '587 '25 mySmtpsvr.UseDefaultCredentials = False mySmtpsvr.Credentials = myCredentials Try Msg.From = New MailAddress("al@verag.ag") Msg.To.Add(recieverMailAdress) Msg.Subject = title '"ERROR - DAKOSY Einarbeitung" Msg.Body = "Uhrzeit: " & Now.ToShortDateString Msg.Body &= vbNewLine Msg.Body &= vbNewLine Msg.Body &= "Fehlermeldung: " & errmsg Msg.Body &= vbNewLine Msg.Body &= vbNewLine Msg.Body &= "Stacktrace: " & errstack Msg.Body &= vbNewLine If zusatz <> "" Then Msg.Body &= "Zusatz: " & zusatz Msg.Body &= vbNewLine End If Msg.Body &= errstack mySmtpsvr.Send(Msg) Catch ex As Exception Try mySmtpsvr.Host = "192.168.0.107" 'bei web.de ' 235 mySmtpsvr.Send(Msg) Catch ex2 As Exception MsgBox(ex.Message & ex.StackTrace) End Try End Try End Sub End Class Public Class ERROR_OP Shared Property SHOW As String = "SHOW" Shared Property MAIL As String = "MAIL" Shared Property TOFILE As String = "TOFILE" End Class