diff --git a/App/EmailProfiler.Common/My Project/AssemblyInfo.vb b/App/EmailProfiler.Common/My Project/AssemblyInfo.vb index d26ac99..e925896 100644 --- a/App/EmailProfiler.Common/My Project/AssemblyInfo.vb +++ b/App/EmailProfiler.Common/My Project/AssemblyInfo.vb @@ -13,7 +13,7 @@ Imports System.Runtime.InteropServices - + @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices ' übernehmen, indem Sie "*" eingeben: ' - - + + diff --git a/App/EmailProfiler.Common/clsWorkEmail.vb b/App/EmailProfiler.Common/clsWorkEmail.vb index cae790b..9e8d04e 100644 --- a/App/EmailProfiler.Common/clsWorkEmail.vb +++ b/App/EmailProfiler.Common/clsWorkEmail.vb @@ -167,8 +167,11 @@ Public Class clsWorkEmail Dim oResult As String = ObjectEx.NotNull(_DB_MSSQL.GetScalarValue(pValidationSQLWithPlaceholders), "") If oResult <> "" Then + Dim oRejectionCodeString = GetRejectionCodeString(CurrentMail.MessageId, ErrorCode.SenderValidationFailed) + 'insert history und exit - InsertHistoryEntryWithStatus(CurrentMail, "REJECTED", oResult) + InsertHistoryEntryWithStatus(CurrentMail, "REJECTED", oRejectionCodeString) + 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, @@ -195,7 +198,10 @@ Public Class clsWorkEmail If CURRENT_ATTMT_COUNT = 0 Then _Logger.Info("### Mail contained no Attachments!! ###") - InsertHistoryEntryWithStatus(CurrentMail, "REJECTED", "No Attachments") + + 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 AddEmailToQueueMSSQL(CurrentMail.MessageId, oBody, "No Attachments", _EmailAccountID) = True Then @@ -219,32 +225,7 @@ Public Class clsWorkEmail Return False End Try End Function - ''' - ''' Method to decide wether we use the old or the new - ''' Rejection E-mail method. - ''' - ''' TODO we have no information about the language of the receiver at the moment - ''' - ''' E-Mail Message ID - ''' Comment - ''' Name oder Reason - Public Function AddTrackingStatusMSSQL(pMessageId As String, pSTATE_TITLE As String, pSTATE_TITLE1 As String, pCOMMENT As String, pADDEDWHO As String) As Boolean - Dim oInsert = $"INSERT INTO [dbo].[TBEMLP_HISTORY_STATE] - ([MESSAGE_ID] - ,[STATE_TITLE] - ,[STATE_TITLE1] - ,[COMMENT] - ,ADDED_WHO) - VALUES - ('{pMessageId}' - ,'{pSTATE_TITLE}' - ,'{pSTATE_TITLE1}' - ,'{pCOMMENT}' - ,'{pADDEDWHO}')" - Return _DB_MSSQL.ExecuteNonQuery(oInsert) - - End Function ''' ''' Method to decide wether we use the old or the new ''' Rejection E-mail method. @@ -837,19 +818,18 @@ Public Class clsWorkEmail 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", "jpg", "gif", "xml", "png", "jpeg"} + 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("Potentially invalid fileExtension [{0}] ...", oATTFilename) + _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.PDFStructureCorrupt, oATTFilename, "") - Else - _Logger.Info("..but graphic extension!") + End If Continue For @@ -1124,6 +1104,31 @@ Public Class clsWorkEmail End Try End Function + Public Function AddTrackingStatusMSSQL(pMessageId As String, pSTATE_TITLE As String, pSTATE_TITLE1 As String, pCOMMENT As String, pADDEDWHO As String) As Boolean + Try + + Dim oInsert = + $"INSERT INTO [dbo].[TBEMLP_HISTORY_STATE] + ([MESSAGE_ID] + ,[STATE_TITLE] + ,[STATE_TITLE1] + ,[COMMENT] + ,ADDED_WHO) + VALUES + ('{pMessageId}' + ,'{pSTATE_TITLE}' + ,'{pSTATE_TITLE1}' + ,'{pCOMMENT}' + ,'{pADDEDWHO}')" + Return _DB_MSSQL.ExecuteNonQuery(oInsert) + + Catch ex As Exception + _Logger.Error(ex) + Return False + End Try + + End Function + Private Function WORK_POLL_STEPS() As Boolean Try Dim oFoundSomething As Boolean = False @@ -1321,4 +1326,16 @@ Public Class clsWorkEmail Return Nothing End Try End Function + + Private Function GetRejectionCodeString(pMessageId As String, pRejectionCode As ErrorCode) As String + + Dim intCode As Integer = DirectCast(pRejectionCode, Integer) + Dim oRejectionCodeString = $"{EmailStrings.ErrorCodePraefix}{intCode}" + + ' Wir wollen im error-Log den Code und die MessageID haben, um die es geht + Dim oInfoMessage = $"Rejection {oRejectionCodeString} triggered for '{pMessageId}'" + _Logger.Error(oInfoMessage) + + Return oRejectionCodeString + End Function End Class