Stage Commit

This commit is contained in:
Developer01
2026-06-23 11:40:54 +02:00
10 changed files with 263 additions and 62 deletions

View File

@@ -24,6 +24,13 @@ Public Class MailContainer
''' </summary>
Public ReadOnly Property MessageId As String
''' <summary>
''' Eine zweite MessageID, in der das Mail-Datum berücksichtigt wird.
''' Wird verwendet wenn MessageId bereits existiert.
''' </summary>
''' <returns></returns>
Public ReadOnly Property MessageId2 As String
''' <summary>
''' The subject, truncated to SUBJECT_MAX_LENGTH characters
''' </summary>
@@ -41,6 +48,7 @@ Public Class MailContainer
MessageIdOriginal = pMail.MessageID
MessageId = StringEx.GetShortHash(pMail.MessageID)
MessageId2 = StringEx.GetShortHash(pMail.MessageID + pMail.Date.ToString())
Subject = ObjectEx.NotNull(pMail.Subject.Truncate(SUBJECT_MAX_LENGTH), String.Empty)
SubjectOriginal = ObjectEx.NotNull(pMail.Subject, String.Empty)

View File

@@ -12,8 +12,8 @@ Imports System.Runtime.InteropServices
<Assembly: AssemblyDescription("")>
<Assembly: AssemblyCompany("")>
<Assembly: AssemblyProduct("DigitalData.EMLProfiler")>
<Assembly: AssemblyCopyright("Copyright © 2025")>
<Assembly: AssemblyTrademark("3.0.10.0")>
<Assembly: AssemblyCopyright("Copyright © 2026")>
<Assembly: AssemblyTrademark("3.5.3.0")>
<Assembly: ComVisible(False)>
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben:
' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("3.6.0.0")>
<Assembly: AssemblyFileVersion("3.6.0.0")>
<Assembly: AssemblyVersion("3.5.3.0")>
<Assembly: AssemblyFileVersion("3.5.3.0")>

View File

@@ -109,53 +109,41 @@ Public Class clsWorkEmail
'TODO: Move all of these CURRENT_MAIL vars into a business object of type mail container
_CurrentMail = New MailContainer(pMailMessage, poUID)
_Logger.Debug($"Working on email from: {_CurrentMail.SenderAddress}...Subject: {pMailMessage.Subject}")
_Logger.Info($"Working on email from: [{_CurrentMail.SenderAddress}] ... Subject: [{_CurrentMail.SubjectOriginal}] ... MessageID: [{_CurrentMail.MessageId}]")
CURRENT_MAIL_BODY_ALL = ""
CURRENT_MAIL_BODY_ANSWER1 = ""
CURRENT_MAIL_BODY_Substr2 = ""
CURRENT_MAIL_SUBJECT = pMailMessage.Subject.ToUpper.EscapeForSQL()
CURRENT_MAIL_SUBJECT = ""
' Dieser Eintrag wird weiter unten wieder überschrieben. Wenn Subject IS NULL --> Exception
'CURRENT_MAIL_SUBJECT = pMailMessage.Subject.ToUpper.EscapeForSQL()
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.Error("Found a MessageID2 already in use! Could not process email!")
Return False
End If
End If
Dim oTempMailExists As Boolean = Save2TempDirectory(_CurrentMail)