EMail Profiler: Test-Projekt kann jetzt EML-Dateien einlesen. / Der erste E-Mail-Anhang darf eine XML-Datei sein

This commit is contained in:
2025-01-16 09:45:28 +01:00
parent 371cace3ef
commit c3d20191b5
13 changed files with 351 additions and 389 deletions

View File

@@ -18,7 +18,7 @@ Public Class clsWorkEmail
Private Const SUBJECT_MAX_LENGTH = 25
Private Const MESSAGE_ID_MAX_LENGTH = 100
Private CurrentMail As MailContainer = Nothing
Private _CurrentMail As MailContainer = Nothing
Private CurrentTempMailPath As String
@@ -48,24 +48,14 @@ Public Class clsWorkEmail
Private ReadOnly _LicenseManager As New LicenseManager
Private ReadOnly _ValidExtensions As List(Of String)
Private ReadOnly _ValidFirstExtensions As List(Of String)
Private ReadOnly _GraphicExtensions As List(Of String)
Private DoubleBytes As Double
Private _worked_email As Boolean = False
'Sub New(LogConf As LogConfig,
' ConStr As String,
' WmConStr As String,
' pUseWindream As Boolean,
' EmailAccountID As Integer,
' EmlProfPraefix As String,
' pRejectionTemplateId As Integer,
' pInfoTemplateId As Integer,
' pConfigData As ConfigData)
Sub New(LogConf As LogConfig,
ConStr As String,
WmConStr As String,
pConfigData As ConfigData)
Sub New(LogConf As LogConfig, ConStr As String, WmConStr As String, pConfigData As ConfigData)
Try
_Logger = LogConf.GetLogger
_LogConfig = LogConf
@@ -78,6 +68,8 @@ Public Class clsWorkEmail
_Logger.Debug($"_RejectionTemplateId: {_RejectionTemplateId}")
_ValidExtensions = New List(Of String) From {"pdf", "xls", "xlsx", "doc", "docx", "ppt", "pptx"}
_ValidFirstExtensions = New List(Of String) From {"xml"}
_ValidFirstExtensions.AddRange(_ValidExtensions)
_GraphicExtensions = New List(Of String) From {"jpg", "bmp", "jpeg", "gif", "png", "xml"}
If _UseWindream Then
@@ -99,6 +91,7 @@ Public Class clsWorkEmail
_Logger.Error(ex)
End Try
End Sub
Public Function WorkEmailMessage(pMailMessage As IMail, poUID As Long, pValidationSQL As String) As Boolean
Try
For Each m As MailBox In pMailMessage.From
@@ -106,7 +99,7 @@ Public Class clsWorkEmail
Next
'TODO: Move all of these CURRENT_MAIL vars into a business object of type mail container
CurrentMail = New MailContainer(pMailMessage, poUID)
_CurrentMail = New MailContainer(pMailMessage, poUID)
_Logger.Debug($"Working on email from: {CURRENT_MAIL_FROM}...Subject: {pMailMessage.Subject}")
CURRENT_MAIL_BODY_ALL = ""
@@ -149,7 +142,7 @@ Public Class clsWorkEmail
_Logger.Info($"Working on email from : {CURRENT_MAIL_FROM}...")
Dim oSql = $"Select COALESCE(MAX(GUID),0) FROM TBEMLP_HISTORY WHERE EMAIL_MSGID = '{CurrentMail.MessageId}'"
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
@@ -157,13 +150,13 @@ Public Class clsWorkEmail
Return True
End If
Dim oTempMailExists As Boolean = Save2TempDirectory(CurrentMail)
Dim oTempMailExists As Boolean = Save2TempDirectory(_CurrentMail)
'Checking wether Mail can be opened
Dim oTempMailAccessible As Boolean = False
If oTempMailExists = False Then
_Logger.Warn("Could not process email [{0}], file does not exist!", CurrentMail.MessageId)
_Logger.Warn("Could not process email [{0}], file does not exist!", _CurrentMail.MessageId)
Return False
End If
@@ -176,7 +169,7 @@ Public Class clsWorkEmail
End Try
If oTempMailAccessible = False Then
_Logger.Warn("Could not process email [{0}], file is not accessible!", CurrentMail.MessageId)
_Logger.Warn("Could not process email [{0}], file is not accessible!", _CurrentMail.MessageId)
Return False
End If
@@ -185,21 +178,21 @@ Public Class clsWorkEmail
If pValidationSQL <> "" Then
Dim oReplaceValues = New Dictionary(Of String, String) From {
{"EMAIL", CurrentMail.SenderAddress},
{"DOMAIN", CurrentMail.SenderDomain}
{"EMAIL", _CurrentMail.SenderAddress},
{"DOMAIN", _CurrentMail.SenderDomain}
}
Dim pValidationSQLWithPlaceholders = _Patterns.ReplaceCustomValues(pValidationSQL, oReplaceValues)
Dim oResult As String = ObjectEx.NotNull(_DB_MSSQL.GetScalarValue(pValidationSQLWithPlaceholders), "")
If oResult <> "" Then
Dim oRejectionCodeString = GetRejectionCodeString(CurrentMail.MessageId, ErrorCode.SenderValidationFailed)
Dim oRejectionCodeString = GetRejectionCodeString(_CurrentMail.MessageId, ErrorCode.SenderValidationFailed)
'insert history und exit
InsertHistoryEntryWithStatus(CurrentMail, "REJECTED", oRejectionCodeString)
AddTrackingStatusMSSQL(CurrentMail.MessageId, oRejectionCodeString, "Email-Adress validation failed", "", "EMailProfiler")
InsertHistoryEntryWithStatus(_CurrentMail, "REJECTED", oRejectionCodeString)
AddTrackingStatusMSSQL(_CurrentMail.MessageId, oRejectionCodeString, "Email-Adress validation failed", "", "EMailProfiler")
AddToEmailQueueMSSQL(CurrentMail.MessageId, oResult, "Email validation failed", _EmailAccountID,
AddToEmailQueueMSSQL(_CurrentMail.MessageId, oResult, "Email validation failed", _EmailAccountID,
_RejectionTemplateId, ErrorCode.SenderValidationFailed, "", "")
' Return early from processing eml
@@ -209,13 +202,13 @@ Public Class clsWorkEmail
End If
If CURRENT_MAIL_SUBJECT.Contains("[PROCESSMANAGER]") Then
Return PROCESS_MANAGER_IN(CurrentMail)
Return ProcessManager_IN(_CurrentMail)
Else
_Logger.Debug("CommonEmail-Process-Sniffer")
Dim oCommonEmailResult = COMMON_EMAIL_IN(CurrentMail)
Dim oCommonEmailResult = CommonEmail_IN(_CurrentMail)
If oCommonEmailResult = False Then
Return False
@@ -224,19 +217,18 @@ Public Class clsWorkEmail
If CURRENT_ATTMT_COUNT = 0 Then
_Logger.Info("### Mail contained no Attachments!! ###")
Dim oRejectionCodeString = GetRejectionCodeString(CurrentMail.MessageId, ErrorCode.NoAttachments)
InsertHistoryEntryWithStatus(CurrentMail, "REJECTED", oRejectionCodeString)
AddTrackingStatusMSSQL(CurrentMail.MessageId, oRejectionCodeString, "No Attachments", "", "EMailProfiler")
Dim oRejectionCodeString = GetRejectionCodeString(_CurrentMail.MessageId, ErrorCode.NoAttachments)
InsertHistoryEntryWithStatus(_CurrentMail, "REJECTED", oRejectionCodeString)
AddTrackingStatusMSSQL(_CurrentMail.MessageId, oRejectionCodeString, "No Attachments", "", "EMailProfiler")
Dim oBody = EmailStrings.EMAIL_NO_FERDS
If AddToEmailQueueMSSQL(CurrentMail.MessageId, oBody, "No Attachments", _EmailAccountID,
If AddToEmailQueueMSSQL(_CurrentMail.MessageId, oBody, "No Attachments", _EmailAccountID,
_RejectionTemplateId, ErrorCode.NoAttachments, "", "") = True Then
CURRENT_ImapObject.DeleteMessageByUID(poUID)
End If
Else
' Jetzt werden die ggf gefundenen Attachment-Fehler überprüft und verarbeitet
Dim oNormalAttachmentsNotValid As Boolean = False
Dim oEmbeddedAttachmentsNotValid As Boolean = False
@@ -246,9 +238,9 @@ Public Class clsWorkEmail
Any(Function(emb) emb.EmbeddedFiles.Any(Function(ext) ext.IsAttachmentValid = False))
If oEmbeddedAttachmentsNotValid = True Then
Dim oRejectionCodeString = GetRejectionCodeString(CurrentMail.MessageId, ErrorCode.EmbeddedFileAttachmentCorrupt)
InsertHistoryEntryWithStatus(CurrentMail, "REJECTED", oRejectionCodeString)
AddTrackingStatusMSSQL(CurrentMail.MessageId, oRejectionCodeString, "Embedded File corrupt", "", "EMailProfiler")
Dim oRejectionCodeString = GetRejectionCodeString(_CurrentMail.MessageId, ErrorCode.EmbeddedFileAttachmentCorrupt)
InsertHistoryEntryWithStatus(_CurrentMail, "REJECTED", oRejectionCodeString)
AddTrackingStatusMSSQL(_CurrentMail.MessageId, oRejectionCodeString, "Embedded File corrupt", "", "EMailProfiler")
SendRejectionMailToSenderIfEmbeddedAttachmentsAreNotValid()
@@ -257,7 +249,7 @@ Public Class clsWorkEmail
Else
If IS_LOCAL_TEST = False Then
InsertHistoryEntry(CurrentMail)
InsertHistoryEntry(_CurrentMail)
End If
oNormalAttachmentsNotValid = EmailAttachments.Any(Function(ext) ext.IsAttachmentValid = False)
@@ -291,7 +283,7 @@ Public Class clsWorkEmail
If oHtmlFilenameList.IsNotNullOrEmpty() Then
AddToEmailQueueMSSQL(CurrentMail.MessageId, "", "Attachment invalid", _EmailAccountID, _InfoTemplateId, ErrorCode.NormalFileAttachmentCorrupt, oHtmlFilenameList, "")
AddToEmailQueueMSSQL(_CurrentMail.MessageId, "", "Attachment invalid", _EmailAccountID, _InfoTemplateId, ErrorCode.NormalFileAttachmentCorrupt, oHtmlFilenameList, "")
End If
End Sub
@@ -305,7 +297,7 @@ Public Class clsWorkEmail
Dim oHtmlFilenameList As String = GetHtmlFilenameList()
If oHtmlFilenameList.IsNotNullOrEmpty() Then
AddToEmailQueueMSSQL(CurrentMail.MessageId, "", "Attachment invalid", _EmailAccountID, _RejectionTemplateId, ErrorCode.EmbeddedFileAttachmentCorrupt, oHtmlFilenameList, "")
AddToEmailQueueMSSQL(_CurrentMail.MessageId, "", "Attachment invalid", _EmailAccountID, _RejectionTemplateId, ErrorCode.EmbeddedFileAttachmentCorrupt, oHtmlFilenameList, "")
End If
End Sub
@@ -323,7 +315,7 @@ Public Class clsWorkEmail
If attachmentItem.IsAttachmentValid = False Or oEmbeddedAttachmentsInvalid = True Then
AddTrackingStatusMSSQL(CurrentMail.MessageId, attachmentItem.OrgFileName, "FILE CONSISTENCY NOT OK", attachmentItem.ErrorCodeComment, "EMail Profiler")
AddTrackingStatusMSSQL(_CurrentMail.MessageId, attachmentItem.OrgFileName, "FILE CONSISTENCY NOT OK", attachmentItem.ErrorCodeComment, "EMail Profiler")
filenameHtmlString += "<li>" + attachmentItem.OrgFileName + "</li>"
End If
@@ -335,7 +327,7 @@ Public Class clsWorkEmail
For Each embeddedItem In attachmentItem.EmbeddedFiles
If embeddedItem.IsAttachmentValid = False Then
AddTrackingStatusMSSQL(CurrentMail.MessageId, embeddedItem.OrgFileName, "EMBEDDED FILE CONSISTENCY NOT OK", embeddedItem.ErrorCodeComment, "EMail Profiler")
AddTrackingStatusMSSQL(_CurrentMail.MessageId, embeddedItem.OrgFileName, "EMBEDDED FILE CONSISTENCY NOT OK", embeddedItem.ErrorCodeComment, "EMail Profiler")
embeddedFilenamesHtmlString += "<li>" + embeddedItem.OrgFileName + "</li>"
End If
@@ -542,7 +534,8 @@ Public Class clsWorkEmail
Return True
End Function
Private Function PROCESS_MANAGER_IN(pCurrentMail As MailContainer) As Boolean
Private Function ProcessManager_IN(pCurrentMail As MailContainer) As Boolean
Try
_Logger.Info(String.Format("PM-related message found....[{0}]", pCurrentMail.Mail.Subject))
@@ -566,8 +559,8 @@ Public Class clsWorkEmail
WM_IDX_BODY_SUBSTR_LENGTH = row("WM_IDX_BODY_SUBSTR_LENGTH")
DeleteMail = row("DELETE_MAIL")
If COPY2HDD(pCurrentMail, row("COPY_2_HDD"), row("PATH_ORIGINAL"), row("PATH_EMAIL_ERRORS"), False) = True Then
EXTRACT_BODY(pCurrentMail)
If Copy2HDD(pCurrentMail, row("COPY_2_HDD"), row("PATH_ORIGINAL"), row("PATH_EMAIL_ERRORS"), False) = True Then
ExtractBody(pCurrentMail)
End If
@@ -583,9 +576,9 @@ Public Class clsWorkEmail
_Logger.Info(String.Format("Keyword contained a : at end...removing it..."))
CURRENT_MAIL_BODY_ANSWER1 = CURRENT_MAIL_BODY_ANSWER1.Replace(":", "")
End If
If GET_WMDOC_INFO() = True Then
If GetWMDocInfo() = True Then
If DT_STEPS.Rows.Count > 0 Then
WORK_POLL_STEPS()
WorkPollSteps()
Else
_Logger.Info("No steps configured for this Profile ....")
End If
@@ -601,7 +594,7 @@ Public Class clsWorkEmail
Return False
End Try
End Function
Dim DoubleBytes As Double
Default Public Property FormatBytes(ByVal BytesCaller As ULong) As String
Get
Try
@@ -632,7 +625,8 @@ Public Class clsWorkEmail
End Set
End Property
Function COMMON_EMAIL_IN(pCurrentMail As MailContainer) As Boolean
Function CommonEmail_IN(pCurrentMail As MailContainer) As Boolean
Try
_Logger.Info(String.Format("COMMON_EMAIL_IN...Subject [{0}]", pCurrentMail.Mail.Subject))
@@ -697,7 +691,7 @@ Public Class clsWorkEmail
_Logger.Warn($"Unexpected Error in Checking RemainingTotalFreeSpace for Storage [{oExtractMainPath}]: {ex.Message}")
End Try
If COPY2HDD(pCurrentMail, oRow("COPY_2_HDD"), oRow("PATH_ORIGINAL"), oRow("PATH_EMAIL_ERRORS"), True) = True Then
If Copy2HDD(pCurrentMail, oRow("COPY_2_HDD"), oRow("PATH_ORIGINAL"), oRow("PATH_EMAIL_ERRORS"), True) = True Then
If ExtractAttachments(pCurrentMail, oExtractMainPath) = True Then
Return True
@@ -781,7 +775,8 @@ Public Class clsWorkEmail
End Try
End Function
Private Function COPY2HDD(pCurrentMail As MailContainer, pShouldCopyToDisk As Boolean, pDestination As String, pPathErrors As String, pUseMessageIdAsFilename As Boolean) As Boolean
Private Function Copy2HDD(pCurrentMail As MailContainer, pShouldCopyToDisk As Boolean, pDestination As String, pPathErrors As String, pUseMessageIdAsFilename As Boolean) As Boolean
Try
If pShouldCopyToDisk = True Then
_Logger.Debug("COPY_2_HDD is ACTIVE!")
@@ -825,7 +820,8 @@ Public Class clsWorkEmail
Return False
End Try
End Function
Private Function EXTRACT_BODY(pCurrentMail As MailContainer)
Private Function ExtractBody(pCurrentMail As MailContainer)
Dim oTable As DataTable = _DB_MSSQL.GetDatatable("SELECT * FROM TBDD_FUNCTION_REGEX WHERE UPPER(FUNCTION_NAME) IN (UPPER('EMAIL_PROFILER - RemoveHTMLText'),UPPER('EMAIL_PROFILER - RemoveHTMLText1'))")
Dim oBodyText As String = ""
@@ -944,14 +940,18 @@ Public Class clsWorkEmail
Return True
End If
Dim oAttachmentCount As Integer = 0
Dim oAttachmentCount As Integer = 0 ' Anzahl gültige Anhänge
Dim AttachmentPosition As Integer = 0 ' Position des Anhangs in der EMail
For Each oAttachment As MimeData In pCurrentMail.Mail.Attachments
_Logger.Info("Working on Attachment [{0}]", oAttachment.SafeFileName)
AttachmentPosition += 1
Dim oEmailAttachment As EmailAttachment = New EmailAttachment() With
{
.OrgFileName = oAttachment.SafeFileName
.OrgFileName = oAttachment.SafeFileName,
.AttachmentPosition = AttachmentPosition
}
EmailAttachments.Add(oEmailAttachment)
@@ -1137,9 +1137,15 @@ Public Class clsWorkEmail
_Logger.Debug("Validate extension of [{0}]", pAttachmentData.OrgFileName)
Dim lowerFilename = pAttachmentData.OrgFileName.ToLower
Dim oIsValidExtension = _ValidExtensions.Any(Function(ext) lowerFilename.EndsWith(ext))
Dim oIsValidExtension As Boolean = False
Dim oIsGraphicExtension = _GraphicExtensions.Any(Function(ext) lowerFilename.EndsWith(ext))
If pAttachmentData.AttachmentPosition = 1 Then
oIsValidExtension = _ValidFirstExtensions.Any(Function(ext) lowerFilename.EndsWith(ext))
Else
oIsValidExtension = _ValidExtensions.Any(Function(ext) lowerFilename.EndsWith(ext))
End If
If oIsValidExtension = False Then
If oIsGraphicExtension = False Then
_Logger.Warn("File has no valid extension, and it has no graphic extension. In this case we have to inform the sender!")
@@ -1153,187 +1159,6 @@ Public Class clsWorkEmail
Return True
End Function
' MP - 15.11.2024 - Logik obsolet
'Private Function EXTRACT_ATTACHMENTS(pCurrentMail As MailContainer, pExtractPath As String, pErrorPath As String)
' _Logger.Debug("In EXTRACT_ATTACHMENTS...")
' _Logger.Debug(String.Format("PATH_TEMP[{0}]", pExtractPath))
' Dim oAttachmentCount As Integer
' oAttachmentCount = 0
' TEMP_WORK_FILES.Clear()
' Try
' If CurrentTempMailPath <> Nothing Then
' If File.Exists(CurrentTempMailPath) Then
' Dim oATTFilename = ""
' For Each oAttachment As MimeData In pCurrentMail.Mail.Attachments
' oATTFilename = oAttachment.SafeFileName.ToString.ToLower
' Dim oValidExtensions = New List(Of String) From {"pdf", "xls", "xlsx", "doc", "docx", "ppt", "pptx"}
' Dim oGraphicExtensions = New List(Of String) From {"jpg", "bmp", "jpeg", "gif", "png", "xml"}
' Dim oValidExt = oValidExtensions.Any(Function(ext) oATTFilename.EndsWith(ext))
' If oValidExt = False Then
' _Logger.Info("Invalid FileExtension [{0}]", oATTFilename)
' Dim GraphicExt = oGraphicExtensions.Any(Function(ext) oATTFilename.EndsWith(ext))
' If GraphicExt = False Then
' Dim oInfo = $"Consistency or extension of attached file {oATTFilename} is not ok."
' AddTrackingStatusMSSQL(CurrentMail.MessageId, oInfo, "PDF CONSISTENCY NOT OK", "Info GUI", "EML_PROF_EXTR_ATT1")
' AddToEmailQueueMSSQL(CurrentMail.MessageId, oInfo, "PDF CONSISTENCY NOT OK", _EmailAccountID,
' _InfoTemplateId, ErrorCode.NormalFileAttachmentCorrupt, oATTFilename, "")
' End If
' Continue For
' End If
' Dim oAttachmentFilePath = ""
' _Logger.Info("Working on Attachment [{0}]", oAttachment.SafeFileName)
' Try
' Dim oFileInfo = New FileInfo(oAttachment.SafeFileName)
' Dim oFilenameWithoutExtension = Path.GetFileNameWithoutExtension(oAttachment.SafeFileName)
' Dim oFilename = StringEx.ConvertTextToSlug(oFilenameWithoutExtension) & oFileInfo.Extension
' 'Dim oAttachmentFileName = $"{CURRENT_MAIL_MESSAGE_ID}~{pCurrentMail.SenderDomain}~{oFilename}"
' Dim oAttachmentFileName = $"{pCurrentMail.MessageId}~Attm{oAttachmentCount}{oFileInfo.Extension}"
' _Logger.Debug("Final Filename for Attachment: [{0}]", oAttachmentFileName)
' Dim oExtractTempPath = Path.Combine(pExtractPath, "Temp")
' If Directory.Exists(oExtractTempPath) = False Then
' Directory.CreateDirectory(oExtractTempPath)
' End If
' oAttachmentFilePath = Path.Combine(oExtractTempPath, oAttachmentFileName)
' _Logger.Debug("Final Path for Attachment: [{0}]", oAttachmentFilePath)
' If File.Exists(oAttachmentFilePath) Then
' _Logger.Warn("File [{0}] already exists!", oAttachmentFilePath)
' File.Delete(oAttachmentFilePath)
' End If
' _Logger.Debug(String.Format("Trying to save attachment [{0}]", oAttachmentFilePath))
' Try
' oAttachment.Save(oAttachmentFilePath)
' 'oAttachment.Save(oAttachmentFileString)
' Dim oFileInfo1 As New FileInfo(oAttachmentFilePath)
' 'ToDo Konsistenz prüfen
' If oFileInfo.Extension.ToLower = ".pdf" Then
' Dim oPDFConsistent As Boolean = True
' Dim oLicenseManager As New LicenseManager
' oLicenseManager.RegisterKEY(GDPictureLicense)
' Dim oGdPicturePDF As New GdPicturePDF()
' ' Lic
' Dim oStatus As GdPictureStatus = oGdPicturePDF.LoadFromFile(oAttachmentFilePath, True)
' If oStatus <> GdPictureStatus.OK Then
' oPDFConsistent = False
' Dim oResult = $"PDF-Consistency of attached file {oATTFilename} is not ok. ({oStatus.ToString})"
' AddTrackingStatusMSSQL(CurrentMail.MessageId, oResult, "PDF CONSISTENCY NOT OK", "Info GUI", "EML_PROF_EXTR_ATT2")
' AddToEmailQueueMSSQL(CurrentMail.MessageId, oResult, "PDF CONSISTENCY NOT OK", _EmailAccountID,
' _InfoTemplateId, ErrorCode.EmbeddedFileAttachmentCorrupt, oATTFilename, "")
' File.Delete(oAttachmentFilePath)
' Continue For
' Else
' Dim embeddedFileCount As Integer = oGdPicturePDF.GetEmbeddedFileCount()
' If embeddedFileCount > 0 Then
' For i As Integer = 0 To embeddedFileCount - 1
' Dim oEmbAttName As String = oGdPicturePDF.GetEmbeddedFileName(i)
' Dim fileDetail As IO.FileInfo
' fileDetail = My.Computer.FileSystem.GetFileInfo(oEmbAttName)
' If oGdPicturePDF.GetStat() = GdPictureStatus.OK Then
' Dim FileSize As Integer = oGdPicturePDF.GetEmbeddedFileSize(i)
' oValidExt = oValidExtensions.Any(Function(ext) oEmbAttName.EndsWith(ext))
' If oValidExt = False Then
' _Logger.Info("Invalid FileExtension of embedded file [{0}]", oEmbAttName)
' Dim GraphicExt = oGraphicExtensions.Any(Function(ext) oEmbAttName.EndsWith(ext))
' If GraphicExt = False Then
' Dim oInfo = $"Consistency or extension of attached file [{oEmbAttName}] is not ok."
' AddTrackingStatusMSSQL(CurrentMail.MessageId, oInfo, "Extension invalid", "Info GUI", "EML_PROF_EXTR_ATT3")
' AddToEmailQueueMSSQL(CurrentMail.MessageId, oInfo, "Extension invalid", _EmailAccountID,
' _InfoTemplateId, ErrorCode.EmbeddedFileAttachmentCorrupt, oEmbAttName, "")
' End If
' Continue For
' End If
' If oGdPicturePDF.GetStat() = GdPictureStatus.OK Then
' Dim FileData As Byte() = New Byte(FileSize) {}
' Dim status As GdPictureStatus = oGdPicturePDF.ExtractEmbeddedFile(0, FileData)
' If status <> GdPictureStatus.OK Or FileSize = 0 Then
' oPDFConsistent = False
' Dim oResult = $"Consistency or PDF-State of embedded file [{oEmbAttName}] is not ok."
' AddTrackingStatusMSSQL(CurrentMail.MessageId, oResult, "PDF CONSISTENCY EMBEDDED FILE NOT OK", "Info GUI", "EML_PROF_EXTR_ATT4")
' AddToEmailQueueMSSQL(CurrentMail.MessageId, oResult, "PDF CONSISTENCY EMBEDDED FILE NOT OK", _EmailAccountID,
' _InfoTemplateId, ErrorCode.EmbeddedFileAttachmentCorrupt, oEmbAttName, "")
' Continue For
' End If
' End If
' End If
' Next
' End If
' End If
' End If
' Dim oFileLength As Long = oFileInfo1.Length
' If oFileLength > 2 Then
' _Logger.Info(String.Format("Attachment saved to [{0}]", oAttachmentFilePath))
' InsertAttachmentHistoryEntry(pCurrentMail, oAttachment.SafeFileName, oAttachmentFileName)
' oAttachmentCount += 1
' Else
' _Logger.Warn($"##!! oFileLength for AttachmentObjects is <2 !!##")
' Dim oResult = $"Consistency of attached file [{oAttachment.SafeFileName}] is not ok."
' AddTrackingStatusMSSQL(CurrentMail.MessageId, oResult, "CONSISTENCY ATTACHED FILE NOT OK", "Info GUI", "EML_PROF_EXTR_ATT5")
' AddToEmailQueueMSSQL(CurrentMail.MessageId, oResult, "CONSISTENCY ATTACHED FILE NOT OK", _EmailAccountID,
' _InfoTemplateId, ErrorCode.EmbeddedFileAttachmentCorrupt, oAttachment.SafeFileName, "")
' Try
' File.Delete(oAttachmentFilePath)
' Catch ex As Exception
' _Logger.Error(ex)
' End Try
' End If
' Catch ex As Exception
' _Logger.Warn($"Error while saving attachment-name: {ex.Message} - AttachmentName: {oAttachmentFilePath}")
' MESSAGE_ERROR = True
' End Try
' Catch ex As Exception
' _Logger.Warn($"Error while creating and saving attachment-name: {ex.Message} - AttachmentName: {oAttachmentFilePath}")
' MESSAGE_ERROR = True
' End Try
' TEMP_WORK_FILES.Add(oAttachmentFilePath)
' Next
' Else
' _Logger.Warn($"If cause 2 EXTRACT_ATTACHMENTS: {CurrentTempMailPath} not existing")
' End If
' Else
' _Logger.Warn($"EXTRACT_ATTACHMENTSIf cause 1: CURRENT_TEMP_MAIL_PATH is NOTHING")
' End If
' CURRENT_ATTMT_COUNT = oAttachmentCount
' If MESSAGE_ERROR = True Then
' WorkTempFiles("delete")
' Return False
' Else
' WorkTempFiles("move")
' Return True
' End If
' Catch ex As Exception
' _Logger.Error(ex)
' MESSAGE_ERROR = True
' Return False
' End Try
'End Function
Private Sub WorkTempFiles(pAction As String)
For Each _file In TEMP_WORK_FILES
_Logger.Debug("Working ({0}) on temp work file: [{1}]", pAction, _file)
@@ -1505,7 +1330,7 @@ Public Class clsWorkEmail
End Function
Private Function WORK_POLL_STEPS() As Boolean
Private Function WorkPollSteps() As Boolean
Try
Dim oFoundSomething As Boolean = False
_worked_email = False
@@ -1523,7 +1348,7 @@ Public Class clsWorkEmail
Dim sql As String = String.Format("SELECT * FROM TBEMLP_POLL_INDEXING_STEPS WHERE STEP_ID = {0} AND ACTIVE = 1", POLL_STEP_GUID)
DT_INDEXING_STEPS = _DB_MSSQL.GetDatatable(sql)
If DT_INDEXING_STEPS.Rows.Count > 0 Then
WORK_INDEXING_STEPS()
WorkIndexingSteps()
Else
_Logger.Info("No Indexing Steps found?! - SQL: " & sql)
End If
@@ -1541,7 +1366,7 @@ Public Class clsWorkEmail
If DT_INDEXING_STEPS.Rows.Count >= 1 Then
_Logger.Info($"An index for direct answer was configured. Therefore it will be used...")
End If
WORK_INDEXING_STEPS()
WorkIndexingSteps()
_worked_email = True
End If
@@ -1563,7 +1388,8 @@ Public Class clsWorkEmail
Return False
End Try
End Function
Private Function WORK_INDEXING_STEPS() As Boolean
Private Function WorkIndexingSteps() As Boolean
Try
For Each row As DataRow In DT_INDEXING_STEPS.Rows
@@ -1583,6 +1409,7 @@ Public Class clsWorkEmail
Return False
End Try
End Function
Private Function IndexFile(oidxname As String, oidxvalue As String, oConcat_act_Value As Boolean)
Dim OArrIndex() As String
@@ -1633,9 +1460,9 @@ Public Class clsWorkEmail
End If
End Function
Private Function GET_WMDOC_INFO() As Boolean
Private Function GetWMDocInfo() As Boolean
Try
Dim oDOC_ID = REGEX_CHECK_DOC_ID(CURRENT_MAIL_SUBJECT.Replace("10636", "133092").Replace("10644", "133092"))
Dim oDOC_ID = RegExCheckDocID(CURRENT_MAIL_SUBJECT.Replace("10636", "133092").Replace("10644", "133092"))
If Not IsNothing(oDOC_ID) Then
Dim oDT_BASE_ATTR As DataTable = _DB_MSSQL.GetDatatableWithConnection("SELECT * FROM BaseAttributes WHERE dwDocID = " & oDOC_ID, _windreamConnectionString)
If Not IsNothing(oDT_BASE_ATTR) Then
@@ -1680,7 +1507,8 @@ Public Class clsWorkEmail
Return False
End Try
End Function
Public Function REGEX_CHECK_DOC_ID(SearchString As String)
Public Function RegExCheckDocID(SearchString As String)
Try
Dim oRegex As New Regex("\[DID#{1}([0-9]+)]{1}")
_Logger.Debug("REGEX_String before replacing: '" & SearchString & "'")