diff --git a/App/DigitalData.EMLProfiler/clsWorkEmail.vb b/App/DigitalData.EMLProfiler/clsWorkEmail.vb
index 3286e05..a1c7c51 100644
--- a/App/DigitalData.EMLProfiler/clsWorkEmail.vb
+++ b/App/DigitalData.EMLProfiler/clsWorkEmail.vb
@@ -69,20 +69,40 @@ Public Class clsWorkEmail
CURRENT_MAIL_SUBJECT = MyEmailMessage.Subject.ToUpper
CURRENT_MAIL_MESSAGE_ID = RemoveIllegalFileNameChars(MyEmailMessage.MessageID)
CURRENT_MAIL_UID = poUID
- 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()
- 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 = System.Guid.NewGuid.ToString()
- End If
+
+
+ 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
- CURRENT_MAIL_MESSAGE_ID = CURRENT_MAIL_MESSAGE_ID.Replace(">", "").Replace("<", "")
- CURRENT_MAIL_MESSAGE_ID = CURRENT_MAIL_MESSAGE_ID.Replace("'", "")
+
+ '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()
+ ' 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 = System.Guid.NewGuid.ToString()
+
+ ' End If
+ 'End If
+ 'CURRENT_MAIL_MESSAGE_ID = CURRENT_MAIL_MESSAGE_ID.Replace(">", "").Replace("<", "")
+ 'CURRENT_MAIL_MESSAGE_ID = CURRENT_MAIL_MESSAGE_ID.Replace("'", "")
If IsNothing(CURRENT_MAIL_SUBJECT) Then
@@ -96,7 +116,7 @@ Public Class clsWorkEmail
Dim osql = $"Select COALESCE(MAX(GUID),0) FROM TBEMLP_HISTORY WHERE EMAIL_MSGID = '{CURRENT_MAIL_MESSAGE_ID}'"
Dim oHistoryID = _DB_MSSQL.Execute_Scalar(osql)
If oHistoryID > 0 Then
- Logger.Info($"Messsage with subject [{CURRENT_MAIL_SUBJECT}] from [{CURRENT_MAIL_FROM}] has already been worked!")
+ Logger.Debug($"Messsage with subject [{CURRENT_MAIL_SUBJECT}] from [{CURRENT_MAIL_FROM}] has already been worked!")
Return True
End If
Dim oTempMailExists As Boolean = SAVE2TEMP()
@@ -142,6 +162,19 @@ Public Class clsWorkEmail
End Try
End Function
+ Private Function Hash(pString As String) As String
+ Using sha1 As Security.Cryptography.SHA1Managed = New Security.Cryptography.SHA1Managed()
+ Dim oHash = sha1.ComputeHash(Text.Encoding.UTF8.GetBytes(pString))
+ Dim oBuilder = New Text.StringBuilder(oHash.Length * 2)
+
+ For Each b As Byte In oHash
+ oBuilder.Append(b.ToString("X2"))
+ Next
+
+ Return oBuilder.ToString()
+ End Using
+ End Function
+
Public Function AddToEmailQueueMSSQL(MessageId As String, BodyText As String, SourceProcedure As String, pEmailAccountId As Integer) As Boolean
Try
diff --git a/App/SERV_EMAIL/SERV_EMAIL.vbproj b/App/SERV_EMAIL/SERV_EMAIL.vbproj
index fcf4d17..c968ec3 100644
--- a/App/SERV_EMAIL/SERV_EMAIL.vbproj
+++ b/App/SERV_EMAIL/SERV_EMAIL.vbproj
@@ -51,6 +51,10 @@
False
..\DigitalData.EMLProfiler\bin\Debug\DigitalData.EMLProfiler.dll
+
+ False
+ ..\..\..\DDMonorepo\Modules.Language\bin\Debug\DigitalData.Modules.Language.dll
+
False
..\..\..\DDMonorepo\Modules.Logging\bin\Debug\DigitalData.Modules.Logging.dll