MS Messaging Logging

This commit is contained in:
Developer01 2025-02-25 11:39:20 +01:00
parent bf8a2971ec
commit bbd97acfc5
3 changed files with 21 additions and 16 deletions

View File

@ -135,6 +135,7 @@ Namespace Mail
Private Function AddAttachments(pMailBuilder As Limilabs.Mail.MailBuilder, pAttachments As List(Of String)) As Limilabs.Mail.MailBuilder Private Function AddAttachments(pMailBuilder As Limilabs.Mail.MailBuilder, pAttachments As List(Of String)) As Limilabs.Mail.MailBuilder
For Each oAttachment In pAttachments For Each oAttachment In pAttachments
Try Try
If oAttachment <> String.Empty Then
' Read attachment from disk, add it to Attachments collection ' Read attachment from disk, add it to Attachments collection
If IO.File.Exists(oAttachment) Then If IO.File.Exists(oAttachment) Then
Logger.Debug("Adding attachment [{0}] to mail.", oAttachment) Logger.Debug("Adding attachment [{0}] to mail.", oAttachment)
@ -142,6 +143,10 @@ Namespace Mail
Else Else
Logger.Warn("Attachment [{0}] does not exist. Skipping.", oAttachment) Logger.Warn("Attachment [{0}] does not exist. Skipping.", oAttachment)
End If End If
Else
Logger.Debug("Attachment is String.Empty")
End If
Catch ex As Exception Catch ex As Exception
Logger.Warn("Could not read or add attachment [{0}]!", oAttachment) Logger.Warn("Could not read or add attachment [{0}]!", oAttachment)
Logger.Error(ex) Logger.Error(ex)

View File

@ -157,7 +157,7 @@ Namespace Mail
End If End If
Catch ex As Exception 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) Logger.Error(ex)
Session.Error = ex Session.Error = ex
@ -175,10 +175,10 @@ Namespace Mail
Logger.Debug("Connecting with [SSL/Connect] on [{0}/{1}]", pSession.Server, pSession.Port) Logger.Debug("Connecting with [SSL/Connect] on [{0}/{1}]", pSession.Server, pSession.Port)
Client.Connect(pSession.Server, pSession.Port) Client.Connect(pSession.Server, pSession.Port)
End If End If
Logger.Info("Connection Successful!") Logger.Debug("Connection (AUTH_SSL) Successful!")
Catch ex As Exception 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.Warn($"Error-message: {ex.Message}")
Logger.Error(ex) Logger.Error(ex)
@ -196,21 +196,21 @@ Namespace Mail
Logger.Debug("Connecting with [STARTTLS/Connect] on [{0}/{1}]", pSession.Server, pSession.Port) Logger.Debug("Connecting with [STARTTLS/Connect] on [{0}/{1}]", pSession.Server, pSession.Port)
Client.Connect(pSession.Server, pSession.Port) Client.Connect(pSession.Server, pSession.Port)
End If End If
Logger.Info("Connection Successful!") Logger.Debug("Connection (AUTH_SSLTLS or AUTH_STARTTLS) Successful!")
Dim oSupportsSTARTTLS As Boolean = SupportsSTARTTLS(Client) Dim oSupportsSTARTTLS As Boolean = SupportsSTARTTLS(Client)
Logger.Debug("Server supports STARTTLS: [{0}]", oSupportsSTARTTLS) Logger.Debug("Server supports STARTTLS: [{0}]", oSupportsSTARTTLS)
If oSupportsSTARTTLS Then If oSupportsSTARTTLS Then
DoSTARTTLS(Client) DoSTARTTLS(Client)
Logger.Info("STARTTLS Successful!") Logger.Debug("STARTTLS Successful!")
Else Else
Logger.Debug("Server does not support STARTTLS. Enabling TLS1.2 instead.") Logger.Debug("Server does not support STARTTLS. Enabling TLS1.2 instead.")
Client.SSLConfiguration.EnabledSslProtocols = Security.Authentication.SslProtocols.Tls12 Client.SSLConfiguration.EnabledSslProtocols = Security.Authentication.SslProtocols.Tls12
End If End If
Catch ex As Exception 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) Logger.Error(ex)
pSession.Error = ex pSession.Error = ex
@ -221,9 +221,9 @@ Namespace Mail
Try Try
Logger.Debug("Auth type [{0}]. Using PLAINTEXT connection.", Session.AuthType) Logger.Debug("Auth type [{0}]. Using PLAINTEXT connection.", Session.AuthType)
Client.Connect(pSession.Server, pSession.Port, useSSL:=False) Client.Connect(pSession.Server, pSession.Port, useSSL:=False)
Logger.Info("Connection Successful!")
Catch ex As Exception 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) Logger.Error(ex)
pSession.Error = ex pSession.Error = ex
@ -246,7 +246,7 @@ Namespace Mail
End If End If
Catch ex As Exception 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) Logger.Error(ex)
pSession.Error = ex pSession.Error = ex

View File

@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben: ' übernehmen, indem Sie "*" eingeben:
' <Assembly: AssemblyVersion("1.0.*")> ' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("1.9.6.0")> <Assembly: AssemblyVersion("1.9.7.0")>
<Assembly: AssemblyFileVersion("1.9.6.0")> <Assembly: AssemblyFileVersion("1.9.7.0")>