Compare commits

...

2 Commits

Author SHA1 Message Date
6193019051 EMailProfiler.Common: Version 3.0.7.0 2024-11-15 13:17:13 +01:00
c170bf7cc4 EmailProfiler.Common: Flag setzen, wenn normales attachment defekt ist.
alte Logik entfernt bzw. auskommentiert
2024-11-15 13:16:27 +01:00
2 changed files with 166 additions and 188 deletions

View File

@ -13,7 +13,7 @@ Imports System.Runtime.InteropServices
<Assembly: AssemblyCompany("")> <Assembly: AssemblyCompany("")>
<Assembly: AssemblyProduct("DigitalData.EMLProfiler")> <Assembly: AssemblyProduct("DigitalData.EMLProfiler")>
<Assembly: AssemblyCopyright("Copyright © 2024")> <Assembly: AssemblyCopyright("Copyright © 2024")>
<Assembly: AssemblyTrademark("3.0.6.0")> <Assembly: AssemblyTrademark("3.0.7.0")>
<Assembly: ComVisible(False)> <Assembly: ComVisible(False)>
@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben: ' übernehmen, indem Sie "*" eingeben:
' <Assembly: AssemblyVersion("1.0.*")> ' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("3.0.6.0")> <Assembly: AssemblyVersion("3.0.7.0")>
<Assembly: AssemblyFileVersion("3.0.6.0")> <Assembly: AssemblyFileVersion("3.0.7.0")>

View File

@ -1,21 +1,17 @@
Imports System.Text.RegularExpressions Imports System.Data.SqlClient
Imports WINDREAMLib
Imports EmailProfiler.Common.ClassCurrent
Imports System.IO Imports System.IO
Imports DigitalData.Modules.Logging Imports System.Text.RegularExpressions
Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Base
Imports System.Threading Imports System.Threading
Imports DigitalData.Modules.Base
Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Patterns
Imports EmailProfiler.Common.ClassCurrent
Imports GdPicture14
Imports Limilabs.Mail Imports Limilabs.Mail
Imports Limilabs.Mail.MIME Imports Limilabs.Mail.MIME
Imports Limilabs.Mail.Headers Imports WINDREAMLib
Imports MailBox = Limilabs.Mail.Headers.MailBox Imports MailBox = Limilabs.Mail.Headers.MailBox
Imports DigitalData.Modules.Patterns
Imports System.Data.SqlClient
Imports GdPicture14
Imports Limilabs.Client.IMAP
Imports System.Net.NetworkInformation
Imports System.Collections.Specialized.BitVector32
Public Class clsWorkEmail Public Class clsWorkEmail
Private Const SUBJECT_MAX_LENGTH = 25 Private Const SUBJECT_MAX_LENGTH = 25
@ -185,7 +181,6 @@ Public Class clsWorkEmail
InsertHistoryEntryWithStatus(CurrentMail, "REJECTED", oRejectionCodeString) InsertHistoryEntryWithStatus(CurrentMail, "REJECTED", oRejectionCodeString)
AddTrackingStatusMSSQL(CurrentMail.MessageId, oRejectionCodeString, "Email-Adress validation failed", "", "EMailProfiler") AddTrackingStatusMSSQL(CurrentMail.MessageId, oRejectionCodeString, "Email-Adress validation failed", "", "EMailProfiler")
'AddEmailToQueueMSSQL(CurrentMail.MessageId, oResult, "Email validation failed", _EmailAccountID)
AddToEmailQueueMSSQL(CurrentMail.MessageId, oResult, "Email validation failed", _EmailAccountID, AddToEmailQueueMSSQL(CurrentMail.MessageId, oResult, "Email validation failed", _EmailAccountID,
_RejectionTemplateId, ErrorCode.SenderValidationFailed, "", "") _RejectionTemplateId, ErrorCode.SenderValidationFailed, "", "")
@ -216,7 +211,6 @@ Public Class clsWorkEmail
AddTrackingStatusMSSQL(CurrentMail.MessageId, oRejectionCodeString, "No Attachments", "", "EMailProfiler") AddTrackingStatusMSSQL(CurrentMail.MessageId, oRejectionCodeString, "No Attachments", "", "EMailProfiler")
Dim oBody = EmailStrings.EMAIL_NO_FERDS Dim oBody = EmailStrings.EMAIL_NO_FERDS
'If AddEmailToQueueMSSQL(CurrentMail.MessageId, oBody, "No Attachments", _EmailAccountID) = True Then
If AddToEmailQueueMSSQL(CurrentMail.MessageId, oBody, "No Attachments", _EmailAccountID, If AddToEmailQueueMSSQL(CurrentMail.MessageId, oBody, "No Attachments", _EmailAccountID,
_RejectionTemplateId, ErrorCode.NoAttachments, "", "") = True Then _RejectionTemplateId, ErrorCode.NoAttachments, "", "") = True Then
CURRENT_ImapObject.DeleteMessageByUID(poUID) CURRENT_ImapObject.DeleteMessageByUID(poUID)
@ -586,7 +580,6 @@ Public Class clsWorkEmail
Return True Return True
Catch ex As Exception Catch ex As Exception
_Logger.Error(ex) _Logger.Error(ex)
'Logger.Debug("Unexpected Error in PROCESS_MANAGER_IN: " & ex.Message & "MESSAGE_ID: " & CURRENT_MAIL_MESSAGE.MessageID)
Return False Return False
End Try End Try
End Function End Function
@ -688,7 +681,6 @@ Public Class clsWorkEmail
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 EXTRACT_ATTACHMENTS(pCurrentMail, oExtractMainPath, oRow("PATH_EMAIL_ERRORS")) = True Then
If ExtractAttachments(pCurrentMail, oExtractMainPath) = True Then If ExtractAttachments(pCurrentMail, oExtractMainPath) = True Then
Return True Return True
Else Else
@ -703,7 +695,6 @@ Public Class clsWorkEmail
Return True Return True
Catch ex As Exception Catch ex As Exception
_Logger.Error(ex) _Logger.Error(ex)
'Logger.Debug("Unexpected Error in PROCESS_MANAGER_IN: " & ex.Message & "MESSAGE_ID: " & CURRENT_MAIL_MESSAGE.MessageID)
Return False Return False
End Try End Try
End Function End Function
@ -730,7 +721,6 @@ Public Class clsWorkEmail
' Subject can be SUBJECT_MAX_LENGTH chars at most, ' Subject can be SUBJECT_MAX_LENGTH chars at most,
' otherwise we run into errors with the path being too long ' otherwise we run into errors with the path being too long
'Dim oSubjectFilename = CURRENT_MAIL_MESSAGE.Subject.Truncate(SUBJECT_MAX_LENGTH) & ".eml"
Dim oSubjectFilename = pCurrentMail.MessageId & ".eml" Dim oSubjectFilename = pCurrentMail.MessageId & ".eml"
oSubjectFilename = StringEx.RemoveInvalidCharacters(oSubjectFilename) oSubjectFilename = StringEx.RemoveInvalidCharacters(oSubjectFilename)
@ -769,7 +759,6 @@ Public Class clsWorkEmail
_Logger.Error(ex) _Logger.Error(ex)
_Logger.Info($"Unexpected error in Save2Temp [{oTempFilename}]") _Logger.Info($"Unexpected error in Save2Temp [{oTempFilename}]")
CurrentTempMailPath = Nothing CurrentTempMailPath = Nothing
'clsLogger.Add("Unexpected Error in COPY2HDD: " & ex.Message & "MESSAGE_ID: " & CURRENT_MAIL_MESSAGE.MessageID, True)
Return False Return False
End Try End Try
@ -778,7 +767,7 @@ Public Class clsWorkEmail
Try Try
If pShouldCopyToDisk = True Then If pShouldCopyToDisk = True Then
_Logger.Debug("COPY_2_HDD is ACTIVE!") _Logger.Debug("COPY_2_HDD is ACTIVE!")
'PATH_ERROR = pPathErrors
If Directory.Exists(pDestination) Then If Directory.Exists(pDestination) Then
Dim oTempFilename = Path.Combine(pDestination, $"{pCurrentMail.MessageId}.eml") Dim oTempFilename = Path.Combine(pDestination, $"{pCurrentMail.MessageId}.eml")
@ -829,7 +818,6 @@ Public Class clsWorkEmail
If Not IsNothing(CURRENT_MAIL_BODY_ALL) Then If Not IsNothing(CURRENT_MAIL_BODY_ALL) Then
Dim oRow = oTable.Rows.Item(0) Dim oRow = oTable.Rows.Item(0)
' CURRENT_MAIL_BODY_ALL = oMsg_email.Body
Dim oPattern1 As String Dim oPattern1 As String
Dim oPattern2 As String Dim oPattern2 As String
Try Try
@ -856,11 +844,6 @@ Public Class clsWorkEmail
Do While oMatch2.Success Do While oMatch2.Success
oClearedBodyText = oClearedBodyText.Replace(oMatch2.Value, "") oClearedBodyText = oClearedBodyText.Replace(oMatch2.Value, "")
'Dim g As Group = m.Groups(1)
'If g.ToString.StartsWith("&") = False Then
' TEMP_HTML_RESULTS.Add(g.ToString())
'End If
oMatch2 = oMatch2.NextMatch() oMatch2 = oMatch2.NextMatch()
Loop Loop
_Logger.Debug($"Cleared bodytext after Regex2 is: {oClearedBodyText}") _Logger.Debug($"Cleared bodytext after Regex2 is: {oClearedBodyText}")
@ -915,7 +898,6 @@ Public Class clsWorkEmail
Return True Return True
Catch ex As Exception Catch ex As Exception
_Logger.Error(ex) _Logger.Error(ex)
'clsLogger.Add("Unexpected Error in COPY2HDD: " & ex.Message & "MESSAGE_ID: " & CURRENT_MAIL_MESSAGE.MessageID, True)
MESSAGE_ERROR = True MESSAGE_ERROR = True
Return False Return False
End Try End Try
@ -1087,6 +1069,7 @@ Public Class clsWorkEmail
CleanUpFilePath(oFilePath) CleanUpFilePath(oFilePath)
pAttachmentData.ErrorCodeValue = ErrorCode.NormalFileAttachmentCorrupt pAttachmentData.ErrorCodeValue = ErrorCode.NormalFileAttachmentCorrupt
pAttachmentData.ErrorCodeComment = "Filesize is zero" pAttachmentData.ErrorCodeComment = "Filesize is zero"
pAttachmentData.IsAttachmentValid = False
Return False Return False
End If End If
@ -1152,188 +1135,186 @@ Public Class clsWorkEmail
Return True Return True
End Function End Function
''' <summary> ' MP - 15.11.2024 - Logik obsolet
''' Diese Funktion wird nicht mehr verwendet!!!! 'Private Function EXTRACT_ATTACHMENTS(pCurrentMail As MailContainer, pExtractPath As String, pErrorPath As String)
''' </summary> ' _Logger.Debug("In EXTRACT_ATTACHMENTS...")
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)) ' _Logger.Debug(String.Format("PATH_TEMP[{0}]", pExtractPath))
Dim oAttachmentCount As Integer ' Dim oAttachmentCount As Integer
oAttachmentCount = 0 ' oAttachmentCount = 0
TEMP_WORK_FILES.Clear() ' TEMP_WORK_FILES.Clear()
Try ' Try
If CurrentTempMailPath <> Nothing Then ' If CurrentTempMailPath <> Nothing Then
If File.Exists(CurrentTempMailPath) Then ' If File.Exists(CurrentTempMailPath) Then
Dim oATTFilename = "" ' Dim oATTFilename = ""
For Each oAttachment As MimeData In pCurrentMail.Mail.Attachments ' For Each oAttachment As MimeData In pCurrentMail.Mail.Attachments
oATTFilename = oAttachment.SafeFileName.ToString.ToLower ' oATTFilename = oAttachment.SafeFileName.ToString.ToLower
Dim oValidExtensions = New List(Of String) From {"pdf", "xls", "xlsx", "doc", "docx", "ppt", "pptx"} ' 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 oGraphicExtensions = New List(Of String) From {"jpg", "bmp", "jpeg", "gif", "png", "xml"}
Dim oValidExt = oValidExtensions.Any(Function(ext) oATTFilename.EndsWith(ext)) ' Dim oValidExt = oValidExtensions.Any(Function(ext) oATTFilename.EndsWith(ext))
If oValidExt = False Then ' If oValidExt = False Then
_Logger.Info("Invalid FileExtension [{0}]", oATTFilename) ' _Logger.Info("Invalid FileExtension [{0}]", oATTFilename)
Dim GraphicExt = oGraphicExtensions.Any(Function(ext) oATTFilename.EndsWith(ext)) ' Dim GraphicExt = oGraphicExtensions.Any(Function(ext) oATTFilename.EndsWith(ext))
If GraphicExt = False Then ' If GraphicExt = False Then
Dim oInfo = $"Consistency or extension of attached file {oATTFilename} is not ok." ' 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") ' AddTrackingStatusMSSQL(CurrentMail.MessageId, oInfo, "PDF CONSISTENCY NOT OK", "Info GUI", "EML_PROF_EXTR_ATT1")
AddToEmailQueueMSSQL(CurrentMail.MessageId, oInfo, "PDF CONSISTENCY NOT OK", _EmailAccountID, ' AddToEmailQueueMSSQL(CurrentMail.MessageId, oInfo, "PDF CONSISTENCY NOT OK", _EmailAccountID,
_InfoTemplateId, ErrorCode.NormalFileAttachmentCorrupt, oATTFilename, "") ' _InfoTemplateId, ErrorCode.NormalFileAttachmentCorrupt, oATTFilename, "")
End If ' End If
Continue For ' Continue For
End If ' End If
Dim oAttachmentFilePath = "" ' Dim oAttachmentFilePath = ""
_Logger.Info("Working on Attachment [{0}]", oAttachment.SafeFileName) ' _Logger.Info("Working on Attachment [{0}]", oAttachment.SafeFileName)
Try ' Try
Dim oFileInfo = New FileInfo(oAttachment.SafeFileName) ' Dim oFileInfo = New FileInfo(oAttachment.SafeFileName)
Dim oFilenameWithoutExtension = Path.GetFileNameWithoutExtension(oAttachment.SafeFileName) ' Dim oFilenameWithoutExtension = Path.GetFileNameWithoutExtension(oAttachment.SafeFileName)
Dim oFilename = StringEx.ConvertTextToSlug(oFilenameWithoutExtension) & oFileInfo.Extension ' Dim oFilename = StringEx.ConvertTextToSlug(oFilenameWithoutExtension) & oFileInfo.Extension
'Dim oAttachmentFileName = $"{CURRENT_MAIL_MESSAGE_ID}~{pCurrentMail.SenderDomain}~{oFilename}" ' 'Dim oAttachmentFileName = $"{CURRENT_MAIL_MESSAGE_ID}~{pCurrentMail.SenderDomain}~{oFilename}"
Dim oAttachmentFileName = $"{pCurrentMail.MessageId}~Attm{oAttachmentCount}{oFileInfo.Extension}" ' Dim oAttachmentFileName = $"{pCurrentMail.MessageId}~Attm{oAttachmentCount}{oFileInfo.Extension}"
_Logger.Debug("Final Filename for Attachment: [{0}]", oAttachmentFileName) ' _Logger.Debug("Final Filename for Attachment: [{0}]", oAttachmentFileName)
Dim oExtractTempPath = Path.Combine(pExtractPath, "Temp") ' Dim oExtractTempPath = Path.Combine(pExtractPath, "Temp")
If Directory.Exists(oExtractTempPath) = False Then ' If Directory.Exists(oExtractTempPath) = False Then
Directory.CreateDirectory(oExtractTempPath) ' Directory.CreateDirectory(oExtractTempPath)
End If ' End If
oAttachmentFilePath = Path.Combine(oExtractTempPath, oAttachmentFileName) ' oAttachmentFilePath = Path.Combine(oExtractTempPath, oAttachmentFileName)
_Logger.Debug("Final Path for Attachment: [{0}]", oAttachmentFilePath) ' _Logger.Debug("Final Path for Attachment: [{0}]", oAttachmentFilePath)
If File.Exists(oAttachmentFilePath) Then ' If File.Exists(oAttachmentFilePath) Then
_Logger.Warn("File [{0}] already exists!", oAttachmentFilePath) ' _Logger.Warn("File [{0}] already exists!", oAttachmentFilePath)
File.Delete(oAttachmentFilePath) ' File.Delete(oAttachmentFilePath)
End If ' End If
_Logger.Debug(String.Format("Trying to save attachment [{0}]", oAttachmentFilePath)) ' _Logger.Debug(String.Format("Trying to save attachment [{0}]", oAttachmentFilePath))
Try ' Try
oAttachment.Save(oAttachmentFilePath) ' oAttachment.Save(oAttachmentFilePath)
'oAttachment.Save(oAttachmentFileString) ' 'oAttachment.Save(oAttachmentFileString)
Dim oFileInfo1 As New FileInfo(oAttachmentFilePath) ' Dim oFileInfo1 As New FileInfo(oAttachmentFilePath)
'ToDo Konsistenz prüfen ' 'ToDo Konsistenz prüfen
If oFileInfo.Extension.ToLower = ".pdf" Then ' If oFileInfo.Extension.ToLower = ".pdf" Then
Dim oPDFConsistent As Boolean = True ' Dim oPDFConsistent As Boolean = True
Dim oLicenseManager As New LicenseManager ' Dim oLicenseManager As New LicenseManager
oLicenseManager.RegisterKEY(GDPictureLicense) ' oLicenseManager.RegisterKEY(GDPictureLicense)
Dim oGdPicturePDF As New GdPicturePDF() ' Dim oGdPicturePDF As New GdPicturePDF()
' Lic ' ' Lic
Dim oStatus As GdPictureStatus = oGdPicturePDF.LoadFromFile(oAttachmentFilePath, True) ' Dim oStatus As GdPictureStatus = oGdPicturePDF.LoadFromFile(oAttachmentFilePath, True)
If oStatus <> GdPictureStatus.OK Then ' If oStatus <> GdPictureStatus.OK Then
oPDFConsistent = False ' oPDFConsistent = False
Dim oResult = $"PDF-Consistency of attached file {oATTFilename} is not ok. ({oStatus.ToString})" ' 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") ' AddTrackingStatusMSSQL(CurrentMail.MessageId, oResult, "PDF CONSISTENCY NOT OK", "Info GUI", "EML_PROF_EXTR_ATT2")
AddToEmailQueueMSSQL(CurrentMail.MessageId, oResult, "PDF CONSISTENCY NOT OK", _EmailAccountID, ' AddToEmailQueueMSSQL(CurrentMail.MessageId, oResult, "PDF CONSISTENCY NOT OK", _EmailAccountID,
_InfoTemplateId, ErrorCode.EmbeddedFileAttachmentCorrupt, oATTFilename, "") ' _InfoTemplateId, ErrorCode.EmbeddedFileAttachmentCorrupt, oATTFilename, "")
File.Delete(oAttachmentFilePath) ' File.Delete(oAttachmentFilePath)
Continue For ' Continue For
Else ' Else
Dim embeddedFileCount As Integer = oGdPicturePDF.GetEmbeddedFileCount() ' Dim embeddedFileCount As Integer = oGdPicturePDF.GetEmbeddedFileCount()
If embeddedFileCount > 0 Then ' If embeddedFileCount > 0 Then
For i As Integer = 0 To embeddedFileCount - 1 ' For i As Integer = 0 To embeddedFileCount - 1
Dim oEmbAttName As String = oGdPicturePDF.GetEmbeddedFileName(i) ' Dim oEmbAttName As String = oGdPicturePDF.GetEmbeddedFileName(i)
Dim fileDetail As IO.FileInfo ' Dim fileDetail As IO.FileInfo
fileDetail = My.Computer.FileSystem.GetFileInfo(oEmbAttName) ' fileDetail = My.Computer.FileSystem.GetFileInfo(oEmbAttName)
If oGdPicturePDF.GetStat() = GdPictureStatus.OK Then ' If oGdPicturePDF.GetStat() = GdPictureStatus.OK Then
Dim FileSize As Integer = oGdPicturePDF.GetEmbeddedFileSize(i) ' Dim FileSize As Integer = oGdPicturePDF.GetEmbeddedFileSize(i)
oValidExt = oValidExtensions.Any(Function(ext) oEmbAttName.EndsWith(ext)) ' oValidExt = oValidExtensions.Any(Function(ext) oEmbAttName.EndsWith(ext))
If oValidExt = False Then ' If oValidExt = False Then
_Logger.Info("Invalid FileExtension of embedded file [{0}]", oEmbAttName) ' _Logger.Info("Invalid FileExtension of embedded file [{0}]", oEmbAttName)
Dim GraphicExt = oGraphicExtensions.Any(Function(ext) oEmbAttName.EndsWith(ext)) ' Dim GraphicExt = oGraphicExtensions.Any(Function(ext) oEmbAttName.EndsWith(ext))
If GraphicExt = False Then ' If GraphicExt = False Then
Dim oInfo = $"Consistency or extension of attached file [{oEmbAttName}] is not ok." ' Dim oInfo = $"Consistency or extension of attached file [{oEmbAttName}] is not ok."
AddTrackingStatusMSSQL(CurrentMail.MessageId, oInfo, "Extension invalid", "Info GUI", "EML_PROF_EXTR_ATT3") ' AddTrackingStatusMSSQL(CurrentMail.MessageId, oInfo, "Extension invalid", "Info GUI", "EML_PROF_EXTR_ATT3")
AddToEmailQueueMSSQL(CurrentMail.MessageId, oInfo, "Extension invalid", _EmailAccountID, ' AddToEmailQueueMSSQL(CurrentMail.MessageId, oInfo, "Extension invalid", _EmailAccountID,
_InfoTemplateId, ErrorCode.EmbeddedFileAttachmentCorrupt, oEmbAttName, "") ' _InfoTemplateId, ErrorCode.EmbeddedFileAttachmentCorrupt, oEmbAttName, "")
End If ' End If
Continue For ' Continue For
End If ' End If
If oGdPicturePDF.GetStat() = GdPictureStatus.OK Then ' If oGdPicturePDF.GetStat() = GdPictureStatus.OK Then
Dim FileData As Byte() = New Byte(FileSize) {} ' Dim FileData As Byte() = New Byte(FileSize) {}
Dim status As GdPictureStatus = oGdPicturePDF.ExtractEmbeddedFile(0, FileData) ' Dim status As GdPictureStatus = oGdPicturePDF.ExtractEmbeddedFile(0, FileData)
If status <> GdPictureStatus.OK Or FileSize = 0 Then ' If status <> GdPictureStatus.OK Or FileSize = 0 Then
oPDFConsistent = False ' oPDFConsistent = False
Dim oResult = $"Consistency or PDF-State of embedded file [{oEmbAttName}] is not ok." ' 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") ' 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, ' AddToEmailQueueMSSQL(CurrentMail.MessageId, oResult, "PDF CONSISTENCY EMBEDDED FILE NOT OK", _EmailAccountID,
_InfoTemplateId, ErrorCode.EmbeddedFileAttachmentCorrupt, oEmbAttName, "") ' _InfoTemplateId, ErrorCode.EmbeddedFileAttachmentCorrupt, oEmbAttName, "")
Continue For ' Continue For
End If ' End If
End If ' End If
End If ' End If
Next ' Next
End If ' End If
End If ' End If
End If ' End If
Dim oFileLength As Long = oFileInfo1.Length ' Dim oFileLength As Long = oFileInfo1.Length
If oFileLength > 2 Then ' If oFileLength > 2 Then
_Logger.Info(String.Format("Attachment saved to [{0}]", oAttachmentFilePath)) ' _Logger.Info(String.Format("Attachment saved to [{0}]", oAttachmentFilePath))
InsertAttachmentHistoryEntry(pCurrentMail, oAttachment.SafeFileName, oAttachmentFileName) ' InsertAttachmentHistoryEntry(pCurrentMail, oAttachment.SafeFileName, oAttachmentFileName)
oAttachmentCount += 1 ' oAttachmentCount += 1
Else ' Else
_Logger.Warn($"##!! oFileLength for AttachmentObjects is <2 !!##") ' _Logger.Warn($"##!! oFileLength for AttachmentObjects is <2 !!##")
Dim oResult = $"Consistency of attached file [{oAttachment.SafeFileName}] is not ok." ' 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") ' 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, ' AddToEmailQueueMSSQL(CurrentMail.MessageId, oResult, "CONSISTENCY ATTACHED FILE NOT OK", _EmailAccountID,
_InfoTemplateId, ErrorCode.EmbeddedFileAttachmentCorrupt, oAttachment.SafeFileName, "") ' _InfoTemplateId, ErrorCode.EmbeddedFileAttachmentCorrupt, oAttachment.SafeFileName, "")
Try ' Try
File.Delete(oAttachmentFilePath) ' File.Delete(oAttachmentFilePath)
Catch ex As Exception ' Catch ex As Exception
_Logger.Error(ex) ' _Logger.Error(ex)
End Try ' End Try
End If ' End If
Catch ex As Exception ' Catch ex As Exception
_Logger.Warn($"Error while saving attachment-name: {ex.Message} - AttachmentName: {oAttachmentFilePath}") ' _Logger.Warn($"Error while saving attachment-name: {ex.Message} - AttachmentName: {oAttachmentFilePath}")
MESSAGE_ERROR = True ' MESSAGE_ERROR = True
End Try ' End Try
Catch ex As Exception ' Catch ex As Exception
_Logger.Warn($"Error while creating and saving attachment-name: {ex.Message} - AttachmentName: {oAttachmentFilePath}") ' _Logger.Warn($"Error while creating and saving attachment-name: {ex.Message} - AttachmentName: {oAttachmentFilePath}")
MESSAGE_ERROR = True ' MESSAGE_ERROR = True
End Try ' End Try
TEMP_WORK_FILES.Add(oAttachmentFilePath) ' TEMP_WORK_FILES.Add(oAttachmentFilePath)
Next ' Next
Else ' Else
_Logger.Warn($"If cause 2 EXTRACT_ATTACHMENTS: {CurrentTempMailPath} not existing") ' _Logger.Warn($"If cause 2 EXTRACT_ATTACHMENTS: {CurrentTempMailPath} not existing")
End If ' End If
Else ' Else
_Logger.Warn($"EXTRACT_ATTACHMENTSIf cause 1: CURRENT_TEMP_MAIL_PATH is NOTHING") ' _Logger.Warn($"EXTRACT_ATTACHMENTSIf cause 1: CURRENT_TEMP_MAIL_PATH is NOTHING")
End If ' End If
CURRENT_ATTMT_COUNT = oAttachmentCount ' CURRENT_ATTMT_COUNT = oAttachmentCount
If MESSAGE_ERROR = True Then ' If MESSAGE_ERROR = True Then
WorkTempFiles("delete") ' WorkTempFiles("delete")
Return False ' Return False
Else ' Else
WorkTempFiles("move") ' WorkTempFiles("move")
Return True ' Return True
End If ' End If
Catch ex As Exception ' Catch ex As Exception
_Logger.Error(ex) ' _Logger.Error(ex)
MESSAGE_ERROR = True ' MESSAGE_ERROR = True
Return False ' Return False
End Try ' End Try
End Function 'End Function
Private Sub WorkTempFiles(pAction As String) Private Sub WorkTempFiles(pAction As String)
For Each _file In TEMP_WORK_FILES For Each _file In TEMP_WORK_FILES
@ -1561,7 +1542,6 @@ Public Class clsWorkEmail
Catch ex As Exception Catch ex As Exception
MESSAGE_ERROR = True MESSAGE_ERROR = True
_Logger.Error(ex) _Logger.Error(ex)
'clsLogger.Add("Unexpected Error in WORK_POLL_STEPS: " & ex.Message & "MESSAGE_ID: " & CURRENT_MAIL_MESSAGE.MessageID, True)
Return False Return False
End Try End Try
End Function End Function
@ -1582,7 +1562,6 @@ Public Class clsWorkEmail
Catch ex As Exception Catch ex As Exception
MESSAGE_ERROR = True MESSAGE_ERROR = True
_Logger.Error(ex) _Logger.Error(ex)
'clsLogger.Add("Unexpected Error in WORK_INDEXING_STEPS: " & ex.Message & "MESSAGE_ID: " & CURRENT_MAIL_MESSAGE.MessageID, True)
Return False Return False
End Try End Try
End Function End Function
@ -1679,7 +1658,6 @@ Public Class clsWorkEmail
Catch ex As Exception Catch ex As Exception
_Logger.Error(ex) _Logger.Error(ex)
'clsLogger.Add("Unexpected Error in GET_DOC_INFO: " & ex.Message & "MESSAGE_ID: " & CURRENT_MAIL_MESSAGE.MessageID)
MESSAGE_ERROR = True MESSAGE_ERROR = True
Return False Return False
End Try End Try