Modules.Messaging: EMail-Adressen validieren

This commit is contained in:
2024-07-24 13:39:38 +02:00
parent 622538225c
commit 9683ec9643
2 changed files with 23 additions and 3 deletions

View File

@@ -65,9 +65,9 @@ Public Class Limilab
End Function
Private Function LOG_Limilab(Log_enabled As Boolean) As Boolean
Private Sub LOG_Limilab(Log_enabled As Boolean)
Log.Enabled = Log_enabled
End Function
End Sub
''' <summary>
''' Tests connection to a given IMAP Server by connecting and doing a simple message query.

View File

@@ -40,8 +40,15 @@ Namespace Mail
Try
Dim oSuccessfulSends As New List(Of String)
Dim oFailedSends As New List(Of String)
Dim oResult As Boolean
For Each oSendToAddress In pSendTo
Dim oResult = SendMailTo(oSendToAddress, pSendFrom, pSubject, pBody, pCreationTime, pAttachments, pTest)
If IsValidEmailAddress(oSendToAddress) Then
oResult = SendMailTo(oSendToAddress, pSendFrom, pSubject, pBody, pCreationTime, pAttachments, pTest)
Else
Logger.Warn("EMail adress [{0}] is NOT valid!", oSendToAddress)
oResult = False
End If
If oResult = True Then
oSuccessfulSends.Add(oSendToAddress & "|" & pSubject)
@@ -143,6 +150,19 @@ Namespace Mail
Return pMailBuilder
End Function
Private Function IsValidEmailAddress(pEmailAddress As String) As Boolean
Try
If pEmailAddress.Contains("@") Then
Dim oAddress = New System.Net.Mail.MailAddress(pEmailAddress)
Return oAddress.Address = pEmailAddress
Else
Return False
End If
Catch ex As Exception
Return False
End Try
End Function
End Class
End Namespace