From e22b108514645aa708f64e09704a58044bce0e22 Mon Sep 17 00:00:00 2001 From: SchreiberM Date: Wed, 20 Mar 2024 10:32:54 +0100 Subject: [PATCH] MS Mesaging 1.9.3.0 SessionState --- Messaging/Mail/MailSender.vb | 41 +++++++++++++++++----------- Messaging/My Project/AssemblyInfo.vb | 4 +-- 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/Messaging/Mail/MailSender.vb b/Messaging/Mail/MailSender.vb index ae0ca4ee..0ebb5608 100644 --- a/Messaging/Mail/MailSender.vb +++ b/Messaging/Mail/MailSender.vb @@ -5,11 +5,12 @@ Namespace Mail Public Class MailSender Inherits BaseClass - Private Property MailSession As MailSession + Public Property MailSession As MailSession Public ReadOnly Property Connected2Server As Boolean Get If MailSession IsNot Nothing AndAlso MailSession.Session IsNot Nothing Then + Return MailSession.Session.Connected Else Return False @@ -36,24 +37,32 @@ Namespace Mail End Function Public Function SendMail(pSendTo As List(Of String), pSendFrom As String, pSubject As String, pBody As String, pCreationTime As Date, pAttachments As List(Of String), pTest As Boolean) As Boolean - Dim oSuccessfulSends As New List(Of String) - Dim oFailedSends As New List(Of String) + Try + Dim oSuccessfulSends As New List(Of String) + Dim oFailedSends As New List(Of String) - For Each oSendToAddress In pSendTo - Dim oResult = SendMailTo(oSendToAddress, pSendFrom, pSubject, pBody, pCreationTime, pAttachments, pTest) + For Each oSendToAddress In pSendTo + Dim oResult = SendMailTo(oSendToAddress, pSendFrom, pSubject, pBody, pCreationTime, pAttachments, pTest) - If oResult = True Then - oSuccessfulSends.Add(oSendToAddress) - Else - oFailedSends.Add(oSendToAddress) - End If - Next + If oResult = True Then + oSuccessfulSends.Add(oSendToAddress & "|" & pSubject) + Else + oFailedSends.Add(oSendToAddress & "|" & pSubject) + End If + Next - Logger.Debug("Sent [{0}] mails.", pSendTo.Count) - Logger.Debug("Successful [{0}]", oSuccessfulSends.Count) - Logger.Debug("Failed [{0}]", oFailedSends.Count) + Logger.Debug("Sent [{0}] mails.", pSendTo.Count) + Logger.Debug("Successful [{0}]", oSuccessfulSends.Count) + Logger.Debug("Failed [{0}]", oFailedSends.Count) + + Return True + Catch ex As Exception + Logger.Warn("Error in SendMail() - while sending mail [{0} - Subject: {1}]", pSendTo, pSubject) + Logger.Error(ex) + + Return False + End Try - Return True End Function Private Function SendMailTo(pSendTo As String, pSendFrom As String, pSubject As String, pBody As String, pCreationTime As Date, pAttachments As List(Of String), pTest As Boolean) @@ -86,7 +95,7 @@ Namespace Mail Return True Catch ex As Exception - Logger.Warn("Error while sending mail to [{0}]", pSendTo) + Logger.Warn("Error in SendMailTo() to [{0} - Subject: {1}]", pSendTo, pSubject) Logger.Error(ex) Return False diff --git a/Messaging/My Project/AssemblyInfo.vb b/Messaging/My Project/AssemblyInfo.vb index aed102f7..5abac6ca 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: ' - - + +