From bbd97acfc5ea3465436bf6a00e4392348c083051 Mon Sep 17 00:00:00 2001 From: Developer01 Date: Tue, 25 Feb 2025 11:39:20 +0100 Subject: [PATCH] MS Messaging Logging --- Messaging/Mail/MailSender.vb | 15 ++++++++++----- Messaging/Mail/MailSession.vb | 18 +++++++++--------- Messaging/My Project/AssemblyInfo.vb | 4 ++-- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/Messaging/Mail/MailSender.vb b/Messaging/Mail/MailSender.vb index 1e283ecf..c453ffd7 100644 --- a/Messaging/Mail/MailSender.vb +++ b/Messaging/Mail/MailSender.vb @@ -135,13 +135,18 @@ Namespace Mail Private Function AddAttachments(pMailBuilder As Limilabs.Mail.MailBuilder, pAttachments As List(Of String)) As Limilabs.Mail.MailBuilder For Each oAttachment In pAttachments Try - ' Read attachment from disk, add it to Attachments collection - If IO.File.Exists(oAttachment) Then - Logger.Debug("Adding attachment [{0}] to mail.", oAttachment) - pMailBuilder.AddAttachment(oAttachment) + If oAttachment <> String.Empty Then + ' Read attachment from disk, add it to Attachments collection + If IO.File.Exists(oAttachment) Then + Logger.Debug("Adding attachment [{0}] to mail.", oAttachment) + pMailBuilder.AddAttachment(oAttachment) + Else + Logger.Warn("Attachment [{0}] does not exist. Skipping.", oAttachment) + End If Else - Logger.Warn("Attachment [{0}] does not exist. Skipping.", oAttachment) + Logger.Debug("Attachment is String.Empty") End If + Catch ex As Exception Logger.Warn("Could not read or add attachment [{0}]!", oAttachment) Logger.Error(ex) diff --git a/Messaging/Mail/MailSession.vb b/Messaging/Mail/MailSession.vb index f45c44be..902669ff 100644 --- a/Messaging/Mail/MailSession.vb +++ b/Messaging/Mail/MailSession.vb @@ -157,7 +157,7 @@ Namespace Mail End If Catch ex As Exception - Logger.Warn("Error while connecting with Auth type OAuth2!") + Logger.Warn("Unexpected Error in ConnectToServer with Auth type OAuth2!") Logger.Error(ex) Session.Error = ex @@ -175,10 +175,10 @@ Namespace Mail Logger.Debug("Connecting with [SSL/Connect] on [{0}/{1}]", pSession.Server, pSession.Port) Client.Connect(pSession.Server, pSession.Port) End If - Logger.Info("Connection Successful!") + Logger.Debug("Connection (AUTH_SSL) Successful!") Catch ex As Exception - Logger.Warn("Error while connecting with Auth type SSL!") + Logger.Warn("Unexpected Error in ConnectToServer with Auth type SSL!") Logger.Warn($"Error-message: {ex.Message}") Logger.Error(ex) @@ -196,21 +196,21 @@ Namespace Mail Logger.Debug("Connecting with [STARTTLS/Connect] on [{0}/{1}]", pSession.Server, pSession.Port) Client.Connect(pSession.Server, pSession.Port) End If - Logger.Info("Connection Successful!") + Logger.Debug("Connection (AUTH_SSLTLS or AUTH_STARTTLS) Successful!") Dim oSupportsSTARTTLS As Boolean = SupportsSTARTTLS(Client) Logger.Debug("Server supports STARTTLS: [{0}]", oSupportsSTARTTLS) If oSupportsSTARTTLS Then DoSTARTTLS(Client) - Logger.Info("STARTTLS Successful!") + Logger.Debug("STARTTLS Successful!") Else Logger.Debug("Server does not support STARTTLS. Enabling TLS1.2 instead.") Client.SSLConfiguration.EnabledSslProtocols = Security.Authentication.SslProtocols.Tls12 End If Catch ex As Exception - Logger.Warn("Error while connecting with Auth type STARTTLS!") + Logger.Warn("Unexpected Error in ConnectToServer with Auth type STARTTLS!") Logger.Error(ex) pSession.Error = ex @@ -221,9 +221,9 @@ Namespace Mail Try Logger.Debug("Auth type [{0}]. Using PLAINTEXT connection.", Session.AuthType) Client.Connect(pSession.Server, pSession.Port, useSSL:=False) - Logger.Info("Connection Successful!") + Catch ex As Exception - Logger.Warn("Error while connecting with Auth type [{0}]!", Session.AuthType) + Logger.Warn("Unexpected Error in ConnectToServer with Auth type [{0}]!", Session.AuthType) Logger.Error(ex) pSession.Error = ex @@ -246,7 +246,7 @@ Namespace Mail End If Catch ex As Exception - Logger.Warn("Error while connecting with Auth type [{0}]!", pSession.AuthType) + Logger.Warn("Unexpected Error in ConnectToServer with Auth type [{0}]!", pSession.AuthType) Logger.Error(ex) pSession.Error = ex diff --git a/Messaging/My Project/AssemblyInfo.vb b/Messaging/My Project/AssemblyInfo.vb index 5d1bd322..ebdfd703 100644 --- a/Messaging/My Project/AssemblyInfo.vb +++ b/Messaging/My Project/AssemblyInfo.vb @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices ' übernehmen, indem Sie "*" eingeben: ' - - + +