EMailService: Fehlerhandling

This commit is contained in:
2024-07-24 14:03:03 +02:00
parent 70b037f3b5
commit 39492f617a
2 changed files with 10 additions and 12 deletions

View File

@@ -26,8 +26,6 @@ Public Class EmailService
Private _MailSender As Mail.MailSender
Private _AttachmentByteData As Byte()
Private _RecentAttachmentByteData As Byte()
Private ReadOnly _messageSend As Boolean = False
Private Enum DatabaseType
Firebird
@@ -453,7 +451,7 @@ Public Class EmailService
Dim oMessageSent = _MailSender.SendMail(oAddresses, oAccount.Sender, oSubject, oBody, oAddedWhen, oAttachments, False)
If oMessageSent Then
If oMessageSent = True Then
oTotalSent.Add(oEmailTo)
oSuccessfulSent.Add(oEmailTo)
@@ -473,14 +471,14 @@ Public Class EmailService
Select Case Database
Case DatabaseType.MSSQL
oSQL = $"UPDATE TBEMLP_EMAIL_OUT SET ERROR_TIMESTAMP = GETDATE(),ERROR_MSG = '{_limilab.ErrorMessage}' WHERE GUID = {oGuid} "
MSSQLInstance.ExecuteNonQuery(oSQL)
If _messageSend = True Then
oSQL = GetSQLUpdateString(oComment, oGuid)
MSSQLInstance.ExecuteNonQuery(oSQL)
_Logger.Info($"EmailID [{oGuid.ToString}] has been send to: {oEmailTo} - although there was an error in connection close!")
Dim oErrorMessage As String
If String.IsNullOrEmpty(_limilab.ErrorMessage) = False Then
oErrorMessage = _limilab.ErrorMessage
Else
oErrorMessage = $"Could not sent email to email adress. Check log!"
End If
oSQL = $"UPDATE TBEMLP_EMAIL_OUT SET EMAIL_SENT = GETDATE(), ERROR_TIMESTAMP = GETDATE(), ERROR_MSG = '{oErrorMessage}' WHERE GUID = {oGuid} "
MSSQLInstance.ExecuteNonQuery(oSQL)
End Select
End If