Wegen Problemen mit doppelte MessageIDs wird zur sicherheite eine zweite erzeugt, und ggf. verwendet.

This commit is contained in:
2026-04-15 08:39:25 +02:00
parent 9dccbee8c9
commit 7204390e85
2 changed files with 21 additions and 29 deletions

View File

@@ -117,45 +117,29 @@ Public Class clsWorkEmail
CURRENT_MAIL_UID = poUID
' 05.06.23
' The MessageID is now replaced by a SHA256 Hash of the MessageID
' The reason is that MessageIDs can be very long,
' which results in the final filepath exceeding the Windream/Windows maximum of 255 chars.
' 28.07.23
' The SHA256 Hash is now truncated to half the size
' which should be a good balance between uniqueness and length
'CURRENT_MAIL_MESSAGE_ID = StringEx.GetShortHash(pMailMessage.MessageID)
'If String.IsNullOrEmpty(CURRENT_MAIL_MESSAGE_ID) Then
' CURRENT_MAIL_MESSAGE_ID = Guid.NewGuid.ToString()
'
'ElseIf CURRENT_MAIL_MESSAGE_ID.Length > MESSAGE_ID_MAX_LENGTH Then
'
' ' MessageIds longer than 100 chars will be replaced with a guid to avoid errors
' ' because of file paths longer than 255 chars.
' CURRENT_MAIL_MESSAGE_ID = Hash(CURRENT_MAIL_MESSAGE_ID)
'
'Else
' ' Default case, should cover most message ids
' CURRENT_MAIL_MESSAGE_ID = CURRENT_MAIL_MESSAGE_ID.Replace(">", "").Replace("<", "")
' CURRENT_MAIL_MESSAGE_ID = CURRENT_MAIL_MESSAGE_ID.Replace("'", "")
'
'End If
If IsNothing(_CurrentMail.SubjectOriginal) Then
If String.IsNullOrEmpty(_CurrentMail.SubjectOriginal) Then
CURRENT_MAIL_SUBJECT = String.Empty
_Logger.Warn("Subject was nothing!")
_Logger.Warn("Subject was empty or nothing!")
Else
CURRENT_MAIL_SUBJECT = _CurrentMail.SubjectOriginal.ToUpper.EscapeForSQL()
_Logger.Debug("Fixed Subject: [{0}]", CURRENT_MAIL_SUBJECT)
End If
' Checking the messageID - could be a duplicate
_Logger.Debug($"messageID: '{_CurrentMail.MessageId}' - messageID2: '{_CurrentMail.MessageId2}'")
Dim oSql = $"Select COALESCE(MAX(GUID),0) FROM TBEMLP_HISTORY WHERE EMAIL_MSGID = '{_CurrentMail.MessageId}'"
Dim oHistoryID = _DB_MSSQL.GetScalarValue(oSql)
If oHistoryID > 0 And IS_LOCAL_TEST = False Then
_Logger.Info($"Message with subject [{_CurrentMail.SubjectOriginal}] from [{_CurrentMail.SenderAddress}] has already been worked!")
Return True
_Logger.Warn("Found a MessageID already in use! Try MessageID2")
oSql = $"Select COALESCE(MAX(GUID),0) FROM TBEMLP_HISTORY WHERE EMAIL_MSGID = '{_CurrentMail.MessageId2}'"
oHistoryID = _DB_MSSQL.GetScalarValue(oSql)
If oHistoryID > 0 And IS_LOCAL_TEST = False Then
_Logger.Warn("Found a MessageID2 already in use!")
End If
End If
Dim oTempMailExists As Boolean = Save2TempDirectory(_CurrentMail)