MS Limilabs etc

This commit is contained in:
2021-10-22 15:24:49 +02:00
parent f2825b9d09
commit fb6f2558f2
449 changed files with 459298 additions and 427010 deletions

View File

@@ -1,28 +1,33 @@
Imports Independentsoft.Email.Mime
Imports System.Text.RegularExpressions
Imports System.Text.RegularExpressions
Imports WINDREAMLib
Imports DigitalData.EMLProfiler.ClassCurrent
Imports System.IO
Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Database
Imports System.Threading
Imports Limilabs.Mail
Imports Limilabs.Mail.MIME
Imports Limilabs.Mail.Headers
Imports MailBox = Limilabs.Mail.Headers.MailBox
Imports DigitalData.Modules.Messaging
Public Class clsWorkEmail
Private Shared Logger As Logger
Private MyLogger As LogConfig
Private _email As clsEmail
Private _limilab As DigitalData.Modules.Messaging.Limilab
Private _DB_MSSQL As clsDatabase
Private _USE_WM As Boolean
Private _windream As clsWindream_allgemein
Private _windream_index As clsWindream_Index
Private _firebird As Firebird
Private _worked_email As Boolean = False
Sub New(LogConf As LogConfig, ConStr As String, FB_DATASOURCE As String, FB_DATABASE As String, FB_USER As String, FB_PW As String, USE_WM As Boolean)
Private _EmailAccountID As Integer = 1
Sub New(LogConf As LogConfig, ConStr As String, FB_DATASOURCE As String, FB_DATABASE As String, FB_USER As String, FB_PW As String, USE_WM As Boolean, EmailAccountID As Integer)
Try
Logger = LogConf.GetLogger
MyLogger = LogConf
_email = New clsEmail(LogConf)
Logger.Debug("clsWorkmail _email initialized")
_limilab = New Limilab(LogConf)
Logger.Debug("Limilab initialized")
_DB_MSSQL = New clsDatabase(LogConf, ConStr)
Logger.Debug("clsWorkmail _email initialized")
_USE_WM = USE_WM
@@ -34,28 +39,41 @@ Public Class clsWorkEmail
If FB_DATASOURCE <> String.Empty Then
_firebird = New Firebird(LogConf, FB_DATASOURCE, FB_DATABASE, FB_USER, FB_PW)
End If
_EmailAccountID = EmailAccountID
Catch ex As Exception
Logger.Error(ex)
End Try
End Sub
Public Function WorkEmailMessage(MyEmailMessage As Message) As Boolean
Public Function WorkEmailMessage(MyEmailMessage As IMail) As Boolean
Try
Logger.Debug($"Working on email from: {MyEmailMessage.From.EmailAddress}...Subject: {MyEmailMessage.Subject}")
For Each m As MailBox In MyEmailMessage.From
CURRENT_MAIL_FROM = m.Address
Next
Logger.Debug($"Working on email from: {CURRENT_MAIL_FROM}...Subject: {MyEmailMessage.Subject}")
CURRENT_MAIL_BODY_ALL = ""
CURRENT_MAIL_BODY_ANSWER1 = ""
CURRENT_MAIL_BODY_Substr2 = ""
CURRENT_MAIL_MESSAGE = MyEmailMessage
CURRENT_MAIL_SUBJECT = MyEmailMessage.Subject.ToUpper
CURRENT_MAIL_MESSAGE_ID = MyEmailMessage.MessageID
If IsNothing(CURRENT_MAIL_MESSAGE_ID) Then
CURRENT_MAIL_MESSAGE_ID = System.Guid.NewGuid.ToString()
Else
If CURRENT_MAIL_MESSAGE_ID.Length = 0 Then
CURRENT_MAIL_MESSAGE_ID = System.Guid.NewGuid.ToString()
End If
End If
CURRENT_MAIL_MESSAGE_ID.Replace(">", "").Replace("<", "")
If IsNothing(CURRENT_MAIL_SUBJECT) Then
CURRENT_MAIL_SUBJECT = ""
Else
Logger.Debug($"Subject: {CURRENT_MAIL_SUBJECT}...")
End If
CURRENT_MAIL_FROM = MyEmailMessage.From.EmailAddress
Logger.Debug($"Working on email from : {CURRENT_MAIL_FROM}...")
Dim oTempMailExists As Boolean = SAVE2TEMP()
'Checking wether Mail can be opened
@@ -77,6 +95,74 @@ Public Class clsWorkEmail
Logger.Info("CommonEmail-Process-Sniffer")
If COMMON_EMAIL_IN() = True Then
INSERT_HISTORY_MSSQL()
If CURRENT_ATTMT_COUNT = 0 Then
Logger.Info("### Mail contained no Attachments!! ###")
Dim oBody = EmailStrings.EMAIL_NO_FERDS
Dim oMessagId = CURRENT_MAIL_MESSAGE.MessageID.Replace("<", "").Replace(">", "")
AddToEmailQueueMSSQL(oMessagId, oBody, "No Attachments", _EmailAccountID)
End If
Return True
Else
Return False
End If
End If
End If
End If
Catch ex As Exception
Logger.Error(ex)
'clsLogger.Add("Unexpected Error in WORK_MAIL: " & ex.Message & "MESSAGE_ID: " & msg.MessageID)
Return False
End Try
End Function
Public Function WorkEmailMessageLimi(MyEmailMessage As IMail) As Boolean
Try
CURRENT_MAIL_BODY_ALL = ""
CURRENT_MAIL_BODY_ANSWER1 = ""
CURRENT_MAIL_BODY_Substr2 = ""
CURRENT_MAIL_MESSAGE = MyEmailMessage
CURRENT_MAIL_SUBJECT = MyEmailMessage.Subject.ToUpper
For Each m As MailBox In MyEmailMessage.From
CURRENT_MAIL_FROM = m.Address
Next
Logger.Debug($"Working on email from: {MyEmailMessage.From.ToString}...Subject: {MyEmailMessage.Subject}")
If IsNothing(CURRENT_MAIL_SUBJECT) Then
CURRENT_MAIL_SUBJECT = ""
Else
Logger.Debug($"Subject: {CURRENT_MAIL_SUBJECT}...")
End If
Logger.Debug($"Working on email from : {CURRENT_MAIL_FROM}...")
Dim oTempMailExists As Boolean = SAVE2TEMP()
'Checking wether Mail can be opened
Dim oTempMailAccessible As Boolean = False
If oTempMailExists = True Then
Try
Dim oFS As FileStream = File.OpenRead(CURRENT_TEMP_MAIL_PATH)
oTempMailAccessible = True
Catch ex As Exception
Logger.Warn($"Could not read the Temp-Mail. Insufficient rights? Message: {ex.Message}")
End Try
If oTempMailAccessible = True Then
MessageError = False
If CURRENT_MAIL_SUBJECT.Contains("[PROCESSMANAGER]") Then
PROCESS_MANAGER_IN()
ElseIf MyEmailMessage.Subject.Contains("[ADDI]") Then
Else
Logger.Info("CommonEmail-Process-Sniffer")
If COMMON_EMAIL_IN() = True Then
INSERT_HISTORY_MSSQL()
If CURRENT_ATTMT_COUNT = 0 Then
Logger.Info("### Mail contained no Attachments!! ###")
Dim oBody = EmailStrings.EMAIL_NO_FERDS
Dim oMessagId = CURRENT_MAIL_MESSAGE.MessageID.Replace("<", "").Replace(">", "")
AddToEmailQueueMSSQL(oMessagId, oBody, "No Attachments", _EmailAccountID)
End If
Return True
Else
Return False
@@ -95,6 +181,68 @@ Public Class clsWorkEmail
Return False
End Try
End Function
Public Sub AddToEmailQueueMSSQL(MessageId As String, BodyText As String, SourceProcedure As String, pEmailAccountId As Integer)
Try
Dim oReference = MessageId
Dim oEmailTo = ""
Dim oSubject = $"{My.Settings.PraefixSubject} - {EmailStrings.EMAIL_SUBJECT_REJECTED}"
Dim oCreatedWho = "DDEmailProfiler"
Dim oMaskedBodyText = BodyText.Replace("'", "''")
Dim oSubjectBodyText = String.Format(EmailStrings.EMAIL_SUBJECT_TEXT, CURRENT_MAIL_SUBJECT).Replace("'", "''")
Dim oCompleteBodyText = oMaskedBodyText & oSubjectBodyText
Dim oFinalBodyText = String.Format(EmailStrings.EMAIL_WRAPPING_TEXT, oCompleteBodyText)
Dim oEmailAddress = CURRENT_MAIL_FROM
If IsNothing(oEmailAddress) OrElse String.IsNullOrWhiteSpace(oEmailAddress) Then
Logger.Warn("Could not find email-address for MessageId {0}", MessageId)
oEmailTo = String.Empty
Else
oEmailTo = oEmailAddress
End If
Logger.Debug("Trying to generate Email:")
Logger.Debug("To: {0}", oEmailTo)
Logger.Debug("Subject: {0}", oSubject)
Logger.Debug("Body {0}", oFinalBodyText)
Dim osql = $"Select MAX(GUID) FROM TBEMLP_HISTORY WHERE EMAIL_MSGID = '{MessageId}'"
Dim oHistoryID = _DB_MSSQL.Execute_Scalar(osql)
If IsNumeric(oHistoryID) Then
Dim oInsert = $"INSERT INTO [dbo].[TBEMLP_EMAIL_OUT] (
[REMINDER_TYPE_ID]
,[SENDING_PROFILE]
,[REFERENCE_ID]
,[REFERENCE_STRING]
,[WF_ID]
,[EMAIL_ADRESS]
,[EMAIL_SUBJ]
,[EMAIL_BODY]
,[COMMENT]
,[ADDED_WHO])
VALUES
(77
,{pEmailAccountId}
,{oHistoryID}
,'{MessageId}'
,77
,'{oEmailTo}'
,'{oSubject}'
,'{oFinalBodyText}'
,'{SourceProcedure}'
,'{oCreatedWho}')"
_DB_MSSQL.Execute_non_Query(oInsert)
Else
Logger.Warn($"!! Could not get oHistoryID in AddToEmailQueueMSSQL [{osql}]")
End If
Catch ex As Exception
Logger.Error(ex)
End Try
End Sub
Private Function PROCESS_MANAGER_IN() As Boolean
Try
Dim oDel_email As Boolean = False
@@ -191,6 +339,7 @@ Public Class clsWorkEmail
If EXTRACT_ATTACHMENTS(oDataRow("PATH_EMAIL_TEMP"), oDataRow("PATH_EMAIL_ERRORS")) = True Then
Return True
Else
Logger.Warn("!##Returning false from EXTRACT_ATTACHMENTS!##")
Return False
End If
Else
@@ -230,16 +379,16 @@ Public Class clsWorkEmail
Next oFileName
Dim oResult As Boolean = False
Dim oTempFilename As String = Path.Combine(oTempPath, CURRENT_MAIL_MESSAGE.GetFileName)
Dim oTempFilename As String = Path.Combine(oTempPath, CURRENT_MAIL_MESSAGE.Subject.Replace(" ", "") & ".eml")
Dim oCounter As Integer = 1
If File.Exists(oTempFilename) = True Then
Do While File.Exists(oTempFilename)
oCounter += 1
oTempFilename = Path.Combine(oTempPath, oCounter & "_" & CURRENT_MAIL_MESSAGE.GetFileName)
oTempFilename = Path.Combine(oTempPath, oCounter & "_" & CURRENT_MAIL_MESSAGE.Subject.Replace(" ", "") & ".eml")
Loop
End If
CURRENT_MAIL_MESSAGE.Save(oTempFilename, True)
CURRENT_MAIL_MESSAGE.Save(oTempFilename)
CURRENT_TEMP_MAIL_PATH = oTempFilename
Logger.Debug($"Email saved to Temppath {CURRENT_TEMP_MAIL_PATH}")
oCounter = 0
@@ -280,7 +429,7 @@ Public Class clsWorkEmail
If messageid = True Then
oTempFilename &= "\" & CURRENT_MAIL_MESSAGE.MessageID & ".eml"
Else
oTempFilename &= "\" & CURRENT_MAIL_MESSAGE.GetFileName
oTempFilename &= "\" & CURRENT_MAIL_MESSAGE.Subject.Replace(" ", "") & ".eml"
End If
Dim cleanPath As String = String.Join("", oTempFilename.Split(Path.GetInvalidPathChars()))
@@ -292,7 +441,7 @@ Public Class clsWorkEmail
Return False
End Try
CURRENT_MAIL_MESSAGE.Save(cleanPath, True)
CURRENT_MAIL_MESSAGE.Save(cleanPath)
Dim oFileInfo As New FileInfo(cleanPath)
Dim oFileLenth As Long = oFileInfo.Length
If oFileLenth > 0 Then
@@ -326,39 +475,42 @@ Public Class clsWorkEmail
Dim oDTFunctionRegex As DataTable = _DB_MSSQL.Return_Datatable("SELECT * FROM TBDD_FUNCTION_REGEX WHERE UPPER(FUNCTION_NAME) IN (UPPER('EMAIL_PROFILER - RemoveHTMLText'),UPPER('EMAIL_PROFILER - RemoveHTMLText1'))")
Dim oMsg_email As New Independentsoft.Email.Mime.Message(CURRENT_TEMP_MAIL_PATH)
'Dim oMsg_email As New Independentsoft.Email.Mime.Message(CURRENT_TEMP_MAIL_PATH)
Dim oBodyText As String = ""
If IsNothing(oMsg_email.Body) Then
Dim oAllBodyParts As New BodyPartCollection()
oAllBodyParts.Add(oMsg_email.BodyParts)
oAllBodyParts.Add(GetChildren(oMsg_email.BodyParts))
For Each bodyPart As BodyPart In oAllBodyParts
If bodyPart.ContentType IsNot Nothing AndAlso bodyPart.ContentType.Type = "text" AndAlso bodyPart.ContentType.SubType = "plain" Then
If oBodyText = String.Empty Then
Logger.Debug(String.Format("BODY1-Text is....#{0}", bodyPart.Body))
oBodyText = bodyPart.Body
Else
Continue For
End If
ElseIf bodyPart.ContentType IsNot Nothing AndAlso bodyPart.ContentType.Type = "text" AndAlso bodyPart.ContentType.SubType = "html" Then
If oBodyText = String.Empty Then
oBodyText = bodyPart.Body
Logger.Debug(String.Format("bodyhtml....#{0}", bodyPart.Body))
Else
Continue For
End If
Logger.Debug(String.Format("bodyhtml....#{0}", bodyPart.Body))
End If
Next
If oBodyText = "" Then
Else
CURRENT_MAIL_BODY_ALL = oBodyText
End If
Else
CURRENT_MAIL_BODY_ALL = oMsg_email.Body
If Not IsNothing(CURRENT_MAIL_MESSAGE.Text) Then
CURRENT_MAIL_BODY_ALL = oBodyText
End If
'If IsNothing(oMsg_email.Body) Then
' Dim oAllBodyParts As New BodyPartCollection()
' oAllBodyParts.Add(oMsg_email.BodyParts)
' oAllBodyParts.Add(GetChildren(oMsg_email.BodyParts))
' For Each bodyPart As BodyPart In oAllBodyParts
' If bodyPart.ContentType IsNot Nothing AndAlso bodyPart.ContentType.Type = "text" AndAlso bodyPart.ContentType.SubType = "plain" Then
' If oBodyText = String.Empty Then
' Logger.Debug(String.Format("BODY1-Text is....#{0}", bodyPart.Body))
' oBodyText = bodyPart.Body
' Else
' Continue For
' End If
' ElseIf bodyPart.ContentType IsNot Nothing AndAlso bodyPart.ContentType.Type = "text" AndAlso bodyPart.ContentType.SubType = "html" Then
' If oBodyText = String.Empty Then
' oBodyText = bodyPart.Body
' Logger.Debug(String.Format("bodyhtml....#{0}", bodyPart.Body))
' Else
' Continue For
' End If
' Logger.Debug(String.Format("bodyhtml....#{0}", bodyPart.Body))
' End If
' Next
' If oBodyText = "" Then
' Else
' CURRENT_MAIL_BODY_ALL = oBodyText
' End If
'Else
' CURRENT_MAIL_BODY_ALL = oMsg_email.Body
'End If
@@ -495,17 +647,19 @@ Public Class clsWorkEmail
PATH_TEMP = pathemailtemp
PATH_ERROR = pathemail_errors
Logger.Debug(String.Format("PATH_TEMP[{0}]", PATH_TEMP))
Dim oAttachmentCount As Integer
oAttachmentCount = 0
Try
If CURRENT_TEMP_MAIL_PATH <> Nothing Then
If File.Exists(CURRENT_TEMP_MAIL_PATH) Then
Dim oCurrentMail As New Independentsoft.Email.Mime.Message(CURRENT_TEMP_MAIL_PATH)
Dim oMSGID = oCurrentMail.MessageID
If IsNothing(oMSGID) Then
oMSGID = System.Guid.NewGuid.ToString()
End If
oMSGID = oMSGID.Replace(">", "").Replace("<", "")
For Each oAttachment As Attachment In oCurrentMail.GetAttachments
Dim oATTFilename = oAttachment.GetFileName.ToString.ToLower
' Dim oCurrentMail As New Independentsoft.Email.Mime.Message(CURRENT_TEMP_MAIL_PATH)
For Each mime As MimeData In CURRENT_MAIL_MESSAGE.Attachments
mime.Save(mime.SafeFileName)
Next
For Each mime As MimeData In CURRENT_MAIL_MESSAGE.Attachments
' For Each oAttachment As Attachment In oCurrentMail.GetAttachments
Dim oATTFilename = mime.SafeFileName 'oAttachment.GetFileName.ToString.ToLower
Dim oValidExt As Boolean = False
If oATTFilename.EndsWith("pdf") Then
oValidExt = True
@@ -527,28 +681,29 @@ Public Class clsWorkEmail
Continue For
End If
Dim oAttachmentFileString
Logger.Info(String.Format(" Working on Attachment [{0}]", oAttachment.GetFileName))
Logger.Info(String.Format(" Working on Attachment [{0}]", mime.SafeFileName)) 'oAttachment.GetFileName))
Try
Dim oFilename = oAttachment.GetFileName
Dim oFilename = mime.SafeFileName 'oAttachment.GetFileName
oFilename = CleanInput(oFilename)
Logger.Debug($"oFilename [{oFilename}]")
If oFilename = String.Empty Then
oFilename = oAttachment.GetFileName
oFilename = mime.SafeFileName 'oAttachment.GetFileName
End If
oAttachmentFileString = Path.Combine(PATH_TEMP, $"{oMSGID}~{oFilename}")
oAttachmentFileString = Path.Combine(PATH_TEMP, $"{CURRENT_MAIL_MESSAGE_ID}~{oFilename}")
Logger.Debug($"oAttachmentFileString [{oAttachmentFileString}]")
If System.IO.File.Exists(oAttachmentFileString) = False Then
Logger.Debug(String.Format("Trying to save attachment [{0}]", oAttachmentFileString))
Try
oAttachment.Save(oAttachmentFileString)
mime.Save(oAttachmentFileString)
'oAttachment.Save(oAttachmentFileString)
Dim oFileInfo As New FileInfo(oAttachmentFileString)
Dim oFileLenth As Long = oFileInfo.Length
If oFileLenth > 0 Then
Logger.Info(String.Format("Attachment saved to [{0}]", oAttachmentFileString))
INSERT_HISTORY_FB(oMSGID, oAttachment.GetFileName)
INSERT_HISTORY_ATTMT_MSSQL(oMSGID, oAttachment.GetFileName)
INSERT_HISTORY_FB(CURRENT_MAIL_MESSAGE_ID, mime.SafeFileName)
INSERT_HISTORY_ATTMT_MSSQL(CURRENT_MAIL_MESSAGE_ID, mime.SafeFileName)
oAttachmentCount += 1
Else
Logger.Warn($"##!! oFileLenth for AttachmentObjects is 0 !!##")
Try
@@ -557,21 +712,22 @@ Public Class clsWorkEmail
Logger.Error(ex)
End Try
MessageError = True
Return False
End If
Catch ex As Exception
Logger.Warn($"Error while saving attachment-name: {ex.Message} - AttachmentName: {oAttachmentFileString}")
MessageError = True
End Try
Else
Logger.Info("EXATTMNT - Attachment (" & oAttachmentFileString & ") already existing!", False, "EXTRACT_ATTACHMENTS")
oAttachmentCount += 1
End If
Catch ex As Exception
Logger.Warn($"Error while creating and saving attachment-name: {ex.Message} - AttachmentName: {oAttachmentFileString}")
MessageError = True
Return False
End Try
Next
Else
@@ -580,7 +736,12 @@ Public Class clsWorkEmail
Else
Logger.Warn($"EXTRACT_ATTACHMENTSIf cause 1: CURRENT_TEMP_MAIL_PATH is NOTHING")
End If
CURRENT_ATTMT_COUNT = oAttachmentCount
If MessageError = True Then
Return False
Else
Return True
End If
Catch ex As Exception
Logger.Error(ex)
'clsLogger.Add("Unexpected Error in COPY2HDD: " & ex.Message & "MESSAGE_ID: " & CURRENT_MAIL_MESSAGE.MessageID, True)
@@ -616,7 +777,7 @@ Public Class clsWorkEmail
Dim ins = $"INSERT INTO TBEMLP_HISTORY (WORK_PROCESS,EMAIL_MSGID,EMAIL_SUBJECT,EMAIL_DATE,EMAIL_BODY,EMAIL_SUBSTRING1,EMAIL_SUBSTRING2,EMAIL_FROM,PROFILE_ID) VALUES " &
$"('{CURRENT_MAIL_PROCESS_NAME}'," &
$"'{CURRENT_MAIL_MESSAGE.MessageID.Replace("<", "").Replace(">", "")}'," &
$"'{CURRENT_MAIL_MESSAGE.Subject}'," &
$"'{CURRENT_MAIL_SUBJECT}'," &
$"'{CURRENT_MAIL_MESSAGE.Date}'," &
$"'{CURRENT_MAIL_BODY_ALL}'," &
$"'{CURRENT_MAIL_BODY_ANSWER1}'," &
@@ -639,8 +800,8 @@ Public Class clsWorkEmail
Dim ins = $"INSERT INTO TBEDM_EMAIL_PROFILER_HISTORY (WORK_PROCESS,EMAIL_MSGID,EMAIL_FROM,EMAIL_SUBJECT,EMAIL_DATETIME,EMAIL_BODY,EMAIL_SUBSTRING1,EMAIL_SUBSTRING2,EMAIL_ATTMT1) VALUES " &
$"('{CURRENT_MAIL_PROCESS_NAME}'," &
$"'{oGUID}'," &
$"'{CURRENT_MAIL_MESSAGE.From.EmailAddress}'," &
$"'{CURRENT_MAIL_MESSAGE.Subject}'," &
$"'{CURRENT_MAIL_FROM}'," &
$"'{CURRENT_MAIL_SUBJECT}'," &
$"'{CURRENT_MAIL_MESSAGE.Date}'," &
$"'{CURRENT_MAIL_BODY_ALL}'," &
$"'{CURRENT_MAIL_BODY_ANSWER1}'," &
@@ -664,7 +825,7 @@ Public Class clsWorkEmail
Dim ins = $"INSERT INTO TBEMLP_HISTORY_ATTACHMENT (WORK_PROCESS,EMAIL_MSGID,EMAIL_FROM,EMAIL_SUBJECT,EMAIL_DATETIME,EMAIL_BODY,EMAIL_ATTMT) VALUES " &
$"('{CURRENT_MAIL_PROCESS_NAME}'," &
$"'{oMSGID}'," &
$"'{CURRENT_MAIL_MESSAGE.From.EmailAddress}'," &
$"'{CURRENT_MAIL_FROM}'," &
$"'{CURRENT_MAIL_MESSAGE.Subject}'," &
$"'{CURRENT_MAIL_MESSAGE.Date}'," &
$"'{CURRENT_MAIL_BODY_ALL}'," &
@@ -676,20 +837,20 @@ Public Class clsWorkEmail
End Try
End Function
Private Function GetChildren(ByVal bodyParts As BodyPartCollection) As BodyPartCollection
'Private Function GetChildren(ByVal bodyParts As BodyPartCollection) As BodyPartCollection
Dim children As New BodyPartCollection()
' Dim children As New BodyPartCollection()
For i As Integer = 0 To bodyParts.Count - 1
children.Add(GetChildren(bodyParts(i).BodyParts))
children.Add(bodyParts(i))
Next
' For i As Integer = 0 To bodyParts.Count - 1
' children.Add(GetChildren(bodyParts(i).BodyParts))
' children.Add(bodyParts(i))
' Next
Return children
End Function
' Return children
'End Function
Private Function EMAIL_DELETE(del As Boolean)
If del = True And MessageError = False Then
_email.DELETE_EMAIL(CURRENT_MAIL_MESSAGE.MessageID)
_limilab.DeleteMessageByUID(CURRENT_MAIL_MESSAGE_ID)
Else
If MessageError = True Then
Logger.Warn($"Did not delete Message [{CURRENT_MAIL_MESSAGE.MessageID}] as there was an MessageError!")