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

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

View File

@ -1,9 +1,5 @@
Imports WINDREAMLib Imports Limilabs.Client.IMAP
Imports Limilabs.Mail Imports WINDREAMLib
Imports Limilabs.Mail.MIME
Imports Limilabs.Mail.Headers
Imports MailBox = Limilabs.Mail.Headers.MailBox
Imports Limilabs.Client.IMAP
Public Class ClassCurrent Public Class ClassCurrent
Public Shared Property WM_DRIVE As String Public Shared Property WM_DRIVE As String

View File

@ -12,6 +12,8 @@ Public Class EmailAttachment
Public ErrorCodeValue As ErrorCode = ErrorCode.Unknown Public ErrorCodeValue As ErrorCode = ErrorCode.Unknown
Public ErrorCodeComment As String = "" Public ErrorCodeComment As String = ""
Public AttachmentPosition As Integer = 0
Public EmbeddedFiles As List(Of EmailAttachment) = New List(Of EmailAttachment) Public EmbeddedFiles As List(Of EmailAttachment) = New List(Of EmailAttachment)
Public ReadOnly Property Extension As String Public ReadOnly Property Extension As String

View File

@ -8,27 +8,32 @@ Public Class MailContainer
''' The Mail object created by Limilabs ''' The Mail object created by Limilabs
''' </summary> ''' </summary>
Public ReadOnly Property Mail As IMail Public ReadOnly Property Mail As IMail
''' <summary> ''' <summary>
''' The IMAP Id coming from the IMAP folder. Used to reference the mail. ''' The IMAP Id coming from the IMAP folder. Used to reference the mail.
''' </summary> ''' </summary>
Public ReadOnly Property ImapId As Integer Public ReadOnly Property ImapId As Integer
''' <summary> ''' <summary>
''' The original MessageID from the eml file ''' The original MessageID from the eml file
''' </summary> ''' </summary>
Public ReadOnly Property MessageIdOriginal As String Public ReadOnly Property MessageIdOriginal As String
''' <summary> ''' <summary>
''' The new MessageID, which is generated by hashing the original MessageID ''' The new MessageID, which is generated by hashing the original MessageID
''' </summary> ''' </summary>
Public ReadOnly Property MessageId As String Public ReadOnly Property MessageId As String
''' <summary> ''' <summary>
''' The subject, truncated to SUBJECT_MAX_LENGTH characters ''' The subject, truncated to SUBJECT_MAX_LENGTH characters
''' </summary> ''' </summary>
Public ReadOnly Property Subject As String Public ReadOnly Property Subject As String
Public ReadOnly Property SubjectOriginal As String Public ReadOnly Property SubjectOriginal As String
Public ReadOnly Property SenderDomain As String Public ReadOnly Property SenderDomain As String
Public ReadOnly Property SenderAddress As String
Public ReadOnly Property SenderAddress As String
Public Sub New(pMail As IMail, pImapId As Integer) Public Sub New(pMail As IMail, pImapId As Integer)
Mail = pMail Mail = pMail

View File

@ -122,14 +122,14 @@
<Compile Include="clsEmail.IMAP.vb" /> <Compile Include="clsEmail.IMAP.vb" />
<Compile Include="Data\ConfigData.vb" /> <Compile Include="Data\ConfigData.vb" />
<Compile Include="Data\EmailAttachment.vb" /> <Compile Include="Data\EmailAttachment.vb" />
<Compile Include="EmailStrings.vb" /> <Compile Include="Enum\EmailStrings.vb" />
<Compile Include="clsEncryption.vb" /> <Compile Include="clsEncryption.vb" />
<Compile Include="clsWindream_allgemein.vb" /> <Compile Include="clsWindream_allgemein.vb" />
<Compile Include="clsWindream_Index.vb" /> <Compile Include="clsWindream_Index.vb" />
<Compile Include="clsWorkEmail.vb" /> <Compile Include="clsWorkEmail.vb" />
<Compile Include="clsWorker.vb" /> <Compile Include="clsWorker.vb" />
<Compile Include="Enum\ErrorCode.vb" /> <Compile Include="Enum\ErrorCode.vb" />
<Compile Include="MailContainer.vb" /> <Compile Include="Data\MailContainer.vb" />
<Compile Include="My Project\AssemblyInfo.vb" /> <Compile Include="My Project\AssemblyInfo.vb" />
<Compile Include="My Project\Application.Designer.vb"> <Compile Include="My Project\Application.Designer.vb">
<AutoGen>True</AutoGen> <AutoGen>True</AutoGen>

View File

@ -18,7 +18,7 @@ Public Class clsWorkEmail
Private Const SUBJECT_MAX_LENGTH = 25 Private Const SUBJECT_MAX_LENGTH = 25
Private Const MESSAGE_ID_MAX_LENGTH = 100 Private Const MESSAGE_ID_MAX_LENGTH = 100
Private CurrentMail As MailContainer = Nothing Private _CurrentMail As MailContainer = Nothing
Private CurrentTempMailPath As String Private CurrentTempMailPath As String
@ -48,24 +48,14 @@ Public Class clsWorkEmail
Private ReadOnly _LicenseManager As New LicenseManager Private ReadOnly _LicenseManager As New LicenseManager
Private ReadOnly _ValidExtensions As List(Of String) Private ReadOnly _ValidExtensions As List(Of String)
Private ReadOnly _ValidFirstExtensions As List(Of String)
Private ReadOnly _GraphicExtensions As List(Of String) Private ReadOnly _GraphicExtensions As List(Of String)
Private DoubleBytes As Double
Private _worked_email As Boolean = False Private _worked_email As Boolean = False
'Sub New(LogConf As LogConfig, Sub New(LogConf As LogConfig, ConStr As String, WmConStr As String, pConfigData As ConfigData)
' 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)
Try Try
_Logger = LogConf.GetLogger _Logger = LogConf.GetLogger
_LogConfig = LogConf _LogConfig = LogConf
@ -78,6 +68,8 @@ Public Class clsWorkEmail
_Logger.Debug($"_RejectionTemplateId: {_RejectionTemplateId}") _Logger.Debug($"_RejectionTemplateId: {_RejectionTemplateId}")
_ValidExtensions = New List(Of String) From {"pdf", "xls", "xlsx", "doc", "docx", "ppt", "pptx"} _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"} _GraphicExtensions = New List(Of String) From {"jpg", "bmp", "jpeg", "gif", "png", "xml"}
If _UseWindream Then If _UseWindream Then
@ -99,6 +91,7 @@ Public Class clsWorkEmail
_Logger.Error(ex) _Logger.Error(ex)
End Try End Try
End Sub End Sub
Public Function WorkEmailMessage(pMailMessage As IMail, poUID As Long, pValidationSQL As String) As Boolean Public Function WorkEmailMessage(pMailMessage As IMail, poUID As Long, pValidationSQL As String) As Boolean
Try Try
For Each m As MailBox In pMailMessage.From For Each m As MailBox In pMailMessage.From
@ -106,7 +99,7 @@ Public Class clsWorkEmail
Next Next
'TODO: Move all of these CURRENT_MAIL vars into a business object of type mail container '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}") _Logger.Debug($"Working on email from: {CURRENT_MAIL_FROM}...Subject: {pMailMessage.Subject}")
CURRENT_MAIL_BODY_ALL = "" CURRENT_MAIL_BODY_ALL = ""
@ -149,7 +142,7 @@ Public Class clsWorkEmail
_Logger.Info($"Working on email from : {CURRENT_MAIL_FROM}...") _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) Dim oHistoryID = _DB_MSSQL.GetScalarValue(oSql)
If oHistoryID > 0 And IS_LOCAL_TEST = False Then If oHistoryID > 0 And IS_LOCAL_TEST = False Then
@ -157,13 +150,13 @@ Public Class clsWorkEmail
Return True Return True
End If End If
Dim oTempMailExists As Boolean = Save2TempDirectory(CurrentMail) Dim oTempMailExists As Boolean = Save2TempDirectory(_CurrentMail)
'Checking wether Mail can be opened 'Checking wether Mail can be opened
Dim oTempMailAccessible As Boolean = False Dim oTempMailAccessible As Boolean = False
If oTempMailExists = False Then 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 Return False
End If End If
@ -176,7 +169,7 @@ Public Class clsWorkEmail
End Try End Try
If oTempMailAccessible = False Then 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 Return False
End If End If
@ -185,21 +178,21 @@ Public Class clsWorkEmail
If pValidationSQL <> "" Then If pValidationSQL <> "" Then
Dim oReplaceValues = New Dictionary(Of String, String) From { Dim oReplaceValues = New Dictionary(Of String, String) From {
{"EMAIL", CurrentMail.SenderAddress}, {"EMAIL", _CurrentMail.SenderAddress},
{"DOMAIN", CurrentMail.SenderDomain} {"DOMAIN", _CurrentMail.SenderDomain}
} }
Dim pValidationSQLWithPlaceholders = _Patterns.ReplaceCustomValues(pValidationSQL, oReplaceValues) Dim pValidationSQLWithPlaceholders = _Patterns.ReplaceCustomValues(pValidationSQL, oReplaceValues)
Dim oResult As String = ObjectEx.NotNull(_DB_MSSQL.GetScalarValue(pValidationSQLWithPlaceholders), "") Dim oResult As String = ObjectEx.NotNull(_DB_MSSQL.GetScalarValue(pValidationSQLWithPlaceholders), "")
If oResult <> "" Then If oResult <> "" Then
Dim oRejectionCodeString = GetRejectionCodeString(CurrentMail.MessageId, ErrorCode.SenderValidationFailed) Dim oRejectionCodeString = GetRejectionCodeString(_CurrentMail.MessageId, ErrorCode.SenderValidationFailed)
'insert history und exit 'insert history und exit
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")
AddToEmailQueueMSSQL(CurrentMail.MessageId, oResult, "Email validation failed", _EmailAccountID, AddToEmailQueueMSSQL(_CurrentMail.MessageId, oResult, "Email validation failed", _EmailAccountID,
_RejectionTemplateId, ErrorCode.SenderValidationFailed, "", "") _RejectionTemplateId, ErrorCode.SenderValidationFailed, "", "")
' Return early from processing eml ' Return early from processing eml
@ -209,13 +202,13 @@ Public Class clsWorkEmail
End If End If
If CURRENT_MAIL_SUBJECT.Contains("[PROCESSMANAGER]") Then If CURRENT_MAIL_SUBJECT.Contains("[PROCESSMANAGER]") Then
Return PROCESS_MANAGER_IN(CurrentMail) Return ProcessManager_IN(_CurrentMail)
Else Else
_Logger.Debug("CommonEmail-Process-Sniffer") _Logger.Debug("CommonEmail-Process-Sniffer")
Dim oCommonEmailResult = COMMON_EMAIL_IN(CurrentMail) Dim oCommonEmailResult = CommonEmail_IN(_CurrentMail)
If oCommonEmailResult = False Then If oCommonEmailResult = False Then
Return False Return False
@ -224,19 +217,18 @@ Public Class clsWorkEmail
If CURRENT_ATTMT_COUNT = 0 Then If CURRENT_ATTMT_COUNT = 0 Then
_Logger.Info("### Mail contained no Attachments!! ###") _Logger.Info("### Mail contained no Attachments!! ###")
Dim oRejectionCodeString = GetRejectionCodeString(CurrentMail.MessageId, ErrorCode.NoAttachments) Dim oRejectionCodeString = GetRejectionCodeString(_CurrentMail.MessageId, ErrorCode.NoAttachments)
InsertHistoryEntryWithStatus(CurrentMail, "REJECTED", oRejectionCodeString) InsertHistoryEntryWithStatus(_CurrentMail, "REJECTED", oRejectionCodeString)
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 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)
End If End If
Else Else
' Jetzt werden die ggf gefundenen Attachment-Fehler überprüft und verarbeitet ' Jetzt werden die ggf gefundenen Attachment-Fehler überprüft und verarbeitet
Dim oNormalAttachmentsNotValid As Boolean = False Dim oNormalAttachmentsNotValid As Boolean = False
Dim oEmbeddedAttachmentsNotValid 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)) Any(Function(emb) emb.EmbeddedFiles.Any(Function(ext) ext.IsAttachmentValid = False))
If oEmbeddedAttachmentsNotValid = True Then If oEmbeddedAttachmentsNotValid = True Then
Dim oRejectionCodeString = GetRejectionCodeString(CurrentMail.MessageId, ErrorCode.EmbeddedFileAttachmentCorrupt) Dim oRejectionCodeString = GetRejectionCodeString(_CurrentMail.MessageId, ErrorCode.EmbeddedFileAttachmentCorrupt)
InsertHistoryEntryWithStatus(CurrentMail, "REJECTED", oRejectionCodeString) InsertHistoryEntryWithStatus(_CurrentMail, "REJECTED", oRejectionCodeString)
AddTrackingStatusMSSQL(CurrentMail.MessageId, oRejectionCodeString, "Embedded File corrupt", "", "EMailProfiler") AddTrackingStatusMSSQL(_CurrentMail.MessageId, oRejectionCodeString, "Embedded File corrupt", "", "EMailProfiler")
SendRejectionMailToSenderIfEmbeddedAttachmentsAreNotValid() SendRejectionMailToSenderIfEmbeddedAttachmentsAreNotValid()
@ -257,7 +249,7 @@ Public Class clsWorkEmail
Else Else
If IS_LOCAL_TEST = False Then If IS_LOCAL_TEST = False Then
InsertHistoryEntry(CurrentMail) InsertHistoryEntry(_CurrentMail)
End If End If
oNormalAttachmentsNotValid = EmailAttachments.Any(Function(ext) ext.IsAttachmentValid = False) oNormalAttachmentsNotValid = EmailAttachments.Any(Function(ext) ext.IsAttachmentValid = False)
@ -291,7 +283,7 @@ Public Class clsWorkEmail
If oHtmlFilenameList.IsNotNullOrEmpty() Then 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 If
End Sub End Sub
@ -305,7 +297,7 @@ Public Class clsWorkEmail
Dim oHtmlFilenameList As String = GetHtmlFilenameList() Dim oHtmlFilenameList As String = GetHtmlFilenameList()
If oHtmlFilenameList.IsNotNullOrEmpty() Then 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 If
End Sub End Sub
@ -323,7 +315,7 @@ Public Class clsWorkEmail
If attachmentItem.IsAttachmentValid = False Or oEmbeddedAttachmentsInvalid = True Then 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>" filenameHtmlString += "<li>" + attachmentItem.OrgFileName + "</li>"
End If End If
@ -335,7 +327,7 @@ Public Class clsWorkEmail
For Each embeddedItem In attachmentItem.EmbeddedFiles For Each embeddedItem In attachmentItem.EmbeddedFiles
If embeddedItem.IsAttachmentValid = False Then 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>" embeddedFilenamesHtmlString += "<li>" + embeddedItem.OrgFileName + "</li>"
End If End If
@ -542,7 +534,8 @@ Public Class clsWorkEmail
Return True Return True
End Function End Function
Private Function PROCESS_MANAGER_IN(pCurrentMail As MailContainer) As Boolean
Private Function ProcessManager_IN(pCurrentMail As MailContainer) As Boolean
Try Try
_Logger.Info(String.Format("PM-related message found....[{0}]", pCurrentMail.Mail.Subject)) _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") WM_IDX_BODY_SUBSTR_LENGTH = row("WM_IDX_BODY_SUBSTR_LENGTH")
DeleteMail = row("DELETE_MAIL") DeleteMail = row("DELETE_MAIL")
If COPY2HDD(pCurrentMail, row("COPY_2_HDD"), row("PATH_ORIGINAL"), row("PATH_EMAIL_ERRORS"), False) = True Then If Copy2HDD(pCurrentMail, row("COPY_2_HDD"), row("PATH_ORIGINAL"), row("PATH_EMAIL_ERRORS"), False) = True Then
EXTRACT_BODY(pCurrentMail) ExtractBody(pCurrentMail)
End If End If
@ -583,9 +576,9 @@ Public Class clsWorkEmail
_Logger.Info(String.Format("Keyword contained a : at end...removing it...")) _Logger.Info(String.Format("Keyword contained a : at end...removing it..."))
CURRENT_MAIL_BODY_ANSWER1 = CURRENT_MAIL_BODY_ANSWER1.Replace(":", "") CURRENT_MAIL_BODY_ANSWER1 = CURRENT_MAIL_BODY_ANSWER1.Replace(":", "")
End If End If
If GET_WMDOC_INFO() = True Then If GetWMDocInfo() = True Then
If DT_STEPS.Rows.Count > 0 Then If DT_STEPS.Rows.Count > 0 Then
WORK_POLL_STEPS() WorkPollSteps()
Else Else
_Logger.Info("No steps configured for this Profile ....") _Logger.Info("No steps configured for this Profile ....")
End If End If
@ -601,7 +594,7 @@ Public Class clsWorkEmail
Return False Return False
End Try End Try
End Function End Function
Dim DoubleBytes As Double
Default Public Property FormatBytes(ByVal BytesCaller As ULong) As String Default Public Property FormatBytes(ByVal BytesCaller As ULong) As String
Get Get
Try Try
@ -632,7 +625,8 @@ Public Class clsWorkEmail
End Set End Set
End Property End Property
Function COMMON_EMAIL_IN(pCurrentMail As MailContainer) As Boolean
Function CommonEmail_IN(pCurrentMail As MailContainer) As Boolean
Try Try
_Logger.Info(String.Format("COMMON_EMAIL_IN...Subject [{0}]", pCurrentMail.Mail.Subject)) _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}") _Logger.Warn($"Unexpected Error in Checking RemainingTotalFreeSpace for Storage [{oExtractMainPath}]: {ex.Message}")
End Try 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 If ExtractAttachments(pCurrentMail, oExtractMainPath) = True Then
Return True Return True
@ -781,7 +775,8 @@ Public Class clsWorkEmail
End Try End Try
End Function 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 Try
If pShouldCopyToDisk = True Then If pShouldCopyToDisk = True Then
_Logger.Debug("COPY_2_HDD is ACTIVE!") _Logger.Debug("COPY_2_HDD is ACTIVE!")
@ -825,7 +820,8 @@ Public Class clsWorkEmail
Return False Return False
End Try End Try
End Function 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 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 = "" Dim oBodyText As String = ""
@ -944,14 +940,18 @@ Public Class clsWorkEmail
Return True Return True
End If 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 For Each oAttachment As MimeData In pCurrentMail.Mail.Attachments
_Logger.Info("Working on Attachment [{0}]", oAttachment.SafeFileName) _Logger.Info("Working on Attachment [{0}]", oAttachment.SafeFileName)
AttachmentPosition += 1
Dim oEmailAttachment As EmailAttachment = New EmailAttachment() With Dim oEmailAttachment As EmailAttachment = New EmailAttachment() With
{ {
.OrgFileName = oAttachment.SafeFileName .OrgFileName = oAttachment.SafeFileName,
.AttachmentPosition = AttachmentPosition
} }
EmailAttachments.Add(oEmailAttachment) EmailAttachments.Add(oEmailAttachment)
@ -1137,9 +1137,15 @@ Public Class clsWorkEmail
_Logger.Debug("Validate extension of [{0}]", pAttachmentData.OrgFileName) _Logger.Debug("Validate extension of [{0}]", pAttachmentData.OrgFileName)
Dim lowerFilename = pAttachmentData.OrgFileName.ToLower 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)) 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 oIsValidExtension = False Then
If oIsGraphicExtension = 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!") _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 Return True
End Function 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) Private Sub WorkTempFiles(pAction As String)
For Each _file In TEMP_WORK_FILES For Each _file In TEMP_WORK_FILES
_Logger.Debug("Working ({0}) on temp work file: [{1}]", pAction, _file) _Logger.Debug("Working ({0}) on temp work file: [{1}]", pAction, _file)
@ -1505,7 +1330,7 @@ Public Class clsWorkEmail
End Function End Function
Private Function WORK_POLL_STEPS() As Boolean Private Function WorkPollSteps() As Boolean
Try Try
Dim oFoundSomething As Boolean = False Dim oFoundSomething As Boolean = False
_worked_email = 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) 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) DT_INDEXING_STEPS = _DB_MSSQL.GetDatatable(sql)
If DT_INDEXING_STEPS.Rows.Count > 0 Then If DT_INDEXING_STEPS.Rows.Count > 0 Then
WORK_INDEXING_STEPS() WorkIndexingSteps()
Else Else
_Logger.Info("No Indexing Steps found?! - SQL: " & sql) _Logger.Info("No Indexing Steps found?! - SQL: " & sql)
End If End If
@ -1541,7 +1366,7 @@ Public Class clsWorkEmail
If DT_INDEXING_STEPS.Rows.Count >= 1 Then If DT_INDEXING_STEPS.Rows.Count >= 1 Then
_Logger.Info($"An index for direct answer was configured. Therefore it will be used...") _Logger.Info($"An index for direct answer was configured. Therefore it will be used...")
End If End If
WORK_INDEXING_STEPS() WorkIndexingSteps()
_worked_email = True _worked_email = True
End If End If
@ -1563,7 +1388,8 @@ Public Class clsWorkEmail
Return False Return False
End Try End Try
End Function End Function
Private Function WORK_INDEXING_STEPS() As Boolean
Private Function WorkIndexingSteps() As Boolean
Try Try
For Each row As DataRow In DT_INDEXING_STEPS.Rows For Each row As DataRow In DT_INDEXING_STEPS.Rows
@ -1583,6 +1409,7 @@ Public Class clsWorkEmail
Return False Return False
End Try End Try
End Function End Function
Private Function IndexFile(oidxname As String, oidxvalue As String, oConcat_act_Value As Boolean) Private Function IndexFile(oidxname As String, oidxvalue As String, oConcat_act_Value As Boolean)
Dim OArrIndex() As String Dim OArrIndex() As String
@ -1633,9 +1460,9 @@ Public Class clsWorkEmail
End If End If
End Function End Function
Private Function GET_WMDOC_INFO() As Boolean Private Function GetWMDocInfo() As Boolean
Try 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 If Not IsNothing(oDOC_ID) Then
Dim oDT_BASE_ATTR As DataTable = _DB_MSSQL.GetDatatableWithConnection("SELECT * FROM BaseAttributes WHERE dwDocID = " & oDOC_ID, _windreamConnectionString) Dim oDT_BASE_ATTR As DataTable = _DB_MSSQL.GetDatatableWithConnection("SELECT * FROM BaseAttributes WHERE dwDocID = " & oDOC_ID, _windreamConnectionString)
If Not IsNothing(oDT_BASE_ATTR) Then If Not IsNothing(oDT_BASE_ATTR) Then
@ -1680,7 +1507,8 @@ Public Class clsWorkEmail
Return False Return False
End Try End Try
End Function End Function
Public Function REGEX_CHECK_DOC_ID(SearchString As String)
Public Function RegExCheckDocID(SearchString As String)
Try Try
Dim oRegex As New Regex("\[DID#{1}([0-9]+)]{1}") Dim oRegex As New Regex("\[DID#{1}([0-9]+)]{1}")
_Logger.Debug("REGEX_String before replacing: '" & SearchString & "'") _Logger.Debug("REGEX_String before replacing: '" & SearchString & "'")

View File

@ -1,4 +1,5 @@
Imports DigitalData.Modules.Base Imports System.IO
Imports DigitalData.Modules.Base
Imports DigitalData.Modules.Database Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Logging Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Messaging.Mail Imports DigitalData.Modules.Messaging.Mail
@ -7,13 +8,13 @@ Imports Limilabs.Mail
Imports Limilabs.Mail.Headers Imports Limilabs.Mail.Headers
Public Class clsWorker Public Class clsWorker
Private ReadOnly Logger As Logger Private ReadOnly _Logger As Logger
Private ReadOnly Fetcher As MailFetcher Private ReadOnly _Fetcher As MailFetcher
Private ReadOnly Database As MSSQLServer Private ReadOnly _Database As MSSQLServer
Private ReadOnly _UseWindream As Boolean = False Private ReadOnly _UseWindream As Boolean = False
Private ReadOnly ClassWindreamAllgemein As clsWindream_allgemein Private ReadOnly ClassWindreamAllgemein As clsWindream_allgemein
Private ReadOnly ClassWindreamIndex As clsWindream_Index Private ReadOnly ClassWindreamIndex As clsWindream_Index
Private ReadOnly ClassWorkMail As clsWorkEmail Private ReadOnly _ClassWorkMail As clsWorkEmail
Private ReadOnly Encryption As clsEncryption Private ReadOnly Encryption As clsEncryption
Private ReadOnly _ProfileId As Integer = 0D Private ReadOnly _ProfileId As Integer = 0D
Private ReadOnly EmailLimitationSender As String = "" Private ReadOnly EmailLimitationSender As String = ""
@ -24,15 +25,15 @@ Public Class clsWorker
Private ReadOnly LocalEmlFile As String = "" Private ReadOnly LocalEmlFile As String = ""
Sub New(pLogConfig As LogConfig, pConnectionString As String, pWindreamConnectionString As String, pPollProfileId As Integer, pConfigData As ConfigData, Optional pLocalEML As String = "") Sub New(pLogConfig As LogConfig, pConnectionString As String, pWindreamConnectionString As String, pPollProfileId As Integer, pConfigData As ConfigData, Optional pLocalEML As String = "")
Logger = pLogConfig.GetLogger _Logger = pLogConfig.GetLogger
'ClassEmailImap = New clsEmailIMAP(pLogConfig) 'ClassEmailImap = New clsEmailIMAP(pLogConfig)
Fetcher = New MailFetcher(pLogConfig) _Fetcher = New MailFetcher(pLogConfig)
Database = New MSSQLServer(pLogConfig, pConnectionString) _Database = New MSSQLServer(pLogConfig, pConnectionString)
_UseWindream = pConfigData.UseWindream _UseWindream = pConfigData.UseWindream
EmailLimitationSender = pConfigData.EmailSenderLimitation EmailLimitationSender = pConfigData.EmailSenderLimitation
If EmailLimitationSender.Contains("@") Then If EmailLimitationSender.Contains("@") Then
Logger.Info("Email Sender Limitation active for address: [{0}]", EmailLimitationSender) _Logger.Info("Email Sender Limitation active for address: [{0}]", EmailLimitationSender)
EmailLimitationEnabled = True EmailLimitationEnabled = True
End If End If
@ -41,7 +42,7 @@ Public Class clsWorker
ClassWindreamIndex = New clsWindream_Index(pLogConfig) ClassWindreamIndex = New clsWindream_Index(pLogConfig)
End If End If
ClassWorkMail = New clsWorkEmail(pLogConfig, pConnectionString, pWindreamConnectionString, pConfigData) _ClassWorkMail = New clsWorkEmail(pLogConfig, pConnectionString, pWindreamConnectionString, pConfigData)
Encryption = New clsEncryption("!35452didalog=", pLogConfig) Encryption = New clsEncryption("!35452didalog=", pLogConfig)
_ProfileId = pPollProfileId _ProfileId = pPollProfileId
@ -50,14 +51,14 @@ Public Class clsWorker
Private Sub DeleteTempFiles() Private Sub DeleteTempFiles()
For Each _file In TEMP_FILES For Each _file In TEMP_FILES
Logger.Debug("Trying to delete temp file: [{0}]", _file) _Logger.Debug("Trying to delete temp file: [{0}]", _file)
If IO.File.Exists(_file) Then If File.Exists(_file) Then
Try Try
IO.File.Delete(_file) File.Delete(_file)
Catch ex As Exception Catch ex As Exception
Logger.Error(ex) _Logger.Error(ex)
Logger.Warn("Could not delete the tempfile from TEMP_FILES: [{0}]", _file) _Logger.Warn("Could not delete the tempfile from TEMP_FILES: [{0}]", _file)
End Try End Try
End If End If
Next Next
@ -65,7 +66,7 @@ Public Class clsWorker
End Sub End Sub
Private Function LoadEmailAccounts() As DataTable Private Function LoadEmailAccounts() As DataTable
Return Database.GetDatatable("SELECT * FROM TBDD_EMAIL_ACCOUNT WHERE ACTIVE = 1") Return _Database.GetDatatable("SELECT * FROM TBDD_EMAIL_ACCOUNT WHERE ACTIVE = 1")
End Function End Function
Private Function LoadPollingProfiles(pProfileId As Integer) As DataTable Private Function LoadPollingProfiles(pProfileId As Integer) As DataTable
@ -77,49 +78,42 @@ Public Class clsWorker
oSQL &= $" AND GUID = {pProfileId}" oSQL &= $" AND GUID = {pProfileId}"
End If End If
Return Database.GetDatatable(oSQL) Return _Database.GetDatatable(oSQL)
End Function End Function
Public Sub Start_WorkingProfiles(Optional LocalEmail As Boolean = False, Optional CallFromService As Boolean = False) Public Sub Start_WorkingProfiles(Optional LocalEmail As Boolean = False)
Try Try
DeleteTempFiles() DeleteTempFiles()
IS_LOCAL_TEST = LocalEmail IS_LOCAL_TEST = LocalEmail
If Database.DBInitialized = False Then If _Database.DBInitialized = False Then
Logger.Warn("Database is not initialized. Exiting.") _Logger.Warn("Database is not initialized. Exiting.")
Exit Sub Exit Sub
End If End If
Logger.Debug("now windream_init... ") _Logger.Debug("now windream_init... ")
If _UseWindream Then If _UseWindream Then
If ClassWindreamAllgemein.Init = False Then If ClassWindreamAllgemein.Init = False Then
Logger.Info("windream could not be initialized!!") _Logger.Info("windream could not be initialized!!")
Exit Sub Exit Sub
Else Else
Logger.Debug("windream_initialized!") _Logger.Debug("windream_initialized!")
End If End If
End If End If
Dim EmailAccountTable As DataTable = LoadEmailAccounts() Dim EmailAccountTable As DataTable = LoadEmailAccounts()
Dim PollingProfileTable = LoadPollingProfiles(_ProfileId) Dim PollingProfileTable = LoadPollingProfiles(_ProfileId)
'Dim oSQLGDPicture = "SELECT LICENSE FROM TBDD_3RD_PARTY_MODULES WHERE ACTIVE = 1"
'If CallFromService = True Then
' oSQLGDPicture = "SELECT LICENSE FROM TBDD_3RD_PARTY_MODULES WHERE NAME = 'GDPICTURE EMAIL_PROFILER'"
'End If
'GDPictureLicense = Database.GetScalarValue(oSQLGDPicture)
If IsNothing(PollingProfileTable) Then If IsNothing(PollingProfileTable) Then
Logger.Warn("Error while fetching Polling Profiles. Exiting.") _Logger.Warn("Error while fetching Polling Profiles. Exiting.")
Exit Sub Exit Sub
End If End If
If PollingProfileTable.Rows.Count = 0 Then If PollingProfileTable.Rows.Count = 0 Then
Logger.Warn("No active Polling Profiles found. Exiting.") _Logger.Warn("No active Polling Profiles found. Exiting.")
Exit Sub Exit Sub
End If End If
Logger.Debug("Count of active profiles: " & PollingProfileTable.Rows.Count.ToString) _Logger.Debug("Count of active profiles: " & PollingProfileTable.Rows.Count.ToString)
For Each oProfile As DataRow In PollingProfileTable.Rows For Each oProfile As DataRow In PollingProfileTable.Rows
@ -128,31 +122,31 @@ Public Class clsWorker
CURRENT_PROFILE_GUID = oProfile.Item("GUID") CURRENT_PROFILE_GUID = oProfile.Item("GUID")
DT_POLL_PROCESS = Nothing DT_POLL_PROCESS = Nothing
Dim sql = String.Format("SELECT * FROM TBEMLP_POLL_PROCESS WHERE PROFILE_ID = {0} AND ACTIVE = 1", CURRENT_PROFILE_GUID) Dim sql = String.Format("SELECT * FROM TBEMLP_POLL_PROCESS WHERE PROFILE_ID = {0} AND ACTIVE = 1", CURRENT_PROFILE_GUID)
DT_POLL_PROCESS = Database.GetDatatable(sql) DT_POLL_PROCESS = _Database.GetDatatable(sql)
If Not IsNothing(DT_POLL_PROCESS) Then If Not IsNothing(DT_POLL_PROCESS) Then
If DT_POLL_PROCESS.Rows.Count = 0 Then If DT_POLL_PROCESS.Rows.Count = 0 Then
Logger.Info("No processes configured for this Email-Profile - " & sql) _Logger.Info("No processes configured for this Email-Profile - " & sql)
Continue For Continue For
Else Else
DT_STEPS = Nothing DT_STEPS = Nothing
DT_STEPS = Database.GetDatatable($"SELECT T.* FROM TBEMLP_POLL_STEPS T,TBEMLP_POLL_PROCESS T1 WHERE T.PROCESS_ID = T1.GUID AND T1.PROFILE_ID = {CURRENT_PROFILE_GUID} AND T1.ACTIVE = 1") DT_STEPS = _Database.GetDatatable($"SELECT T.* FROM TBEMLP_POLL_STEPS T,TBEMLP_POLL_PROCESS T1 WHERE T.PROCESS_ID = T1.GUID AND T1.PROFILE_ID = {CURRENT_PROFILE_GUID} AND T1.ACTIVE = 1")
End If End If
Else Else
Logger.Warn("DT_POLL_PROCESS is nothing") _Logger.Warn("DT_POLL_PROCESS is nothing")
Continue For Continue For
End If End If
CURRENT_EMAIL_GUID = 0 CURRENT_EMAIL_GUID = 0
CURRENT_POLL_TYPE = oProfile.Item("POLL_TYPE") CURRENT_POLL_TYPE = oProfile.Item("POLL_TYPE")
Logger.Debug(String.Format("Working on profile: ({0}-{1}-{2}) ", oProfile.Item("GUID"), oProfile.Item("PROFILE_NAME"), CURRENT_POLL_TYPE)) _Logger.Debug(String.Format("Working on profile: ({0}-{1}-{2}) ", oProfile.Item("GUID"), oProfile.Item("PROFILE_NAME"), CURRENT_POLL_TYPE))
CURRENT_EMAIL_GUID = oProfile.Item("EMAIL_CONF_ID") CURRENT_EMAIL_GUID = oProfile.Item("EMAIL_CONF_ID")
Dim FilteredRows As List(Of DataRow) = EmailAccountTable. Dim FilteredRows As List(Of DataRow) = EmailAccountTable.
Select($"GUID = {CURRENT_EMAIL_GUID}"). Select($"GUID = {CURRENT_EMAIL_GUID}").
ToList() ToList()
Logger.Debug("FilteredRows: " & FilteredRows.Count) _Logger.Debug("FilteredRows: " & FilteredRows.Count)
If FilteredRows.Count = 1 Then If FilteredRows.Count = 1 Then
Dim oRow = FilteredRows(0) Dim oRow = FilteredRows(0)
@ -165,18 +159,18 @@ Public Class clsWorker
Dim oMailArchiveFolder = oRow("ARCHIVE_FOLDER") Dim oMailArchiveFolder = oRow("ARCHIVE_FOLDER")
Dim oMailAuthType = oRow("AUTH_TYPE") Dim oMailAuthType = oRow("AUTH_TYPE")
Logger.Debug("Mail Server: {0}", oMailServer) _Logger.Debug("Mail Server: {0}", oMailServer)
Logger.Debug("Mail From: {0}", oMailFrom) _Logger.Debug("Mail From: {0}", oMailFrom)
Dim PWPlain = Encryption.DecryptData(oMailPassword) Dim PWPlain = Encryption.DecryptData(oMailPassword)
If Not IsNothing(PWPlain) Then If Not IsNothing(PWPlain) Then
If PWPlain <> "" Then If PWPlain <> "" Then
oMailPassword = PWPlain oMailPassword = PWPlain
Else Else
Logger.Warn("PWPlain is string.empty - Could not decrypt passwort") _Logger.Warn("PWPlain is string.empty - Could not decrypt passwort")
End If End If
Else Else
Logger.Warn("PWPlain is nothing - Could not decrypt passwort") _Logger.Warn("PWPlain is nothing - Could not decrypt passwort")
End If End If
CURRENT_WORKMAIL_UID_LIST.Clear() CURRENT_WORKMAIL_UID_LIST.Clear()
@ -192,26 +186,24 @@ Public Class clsWorker
oPollResult = FetchMessages(oMailServer, oMailPortIn, oMailUser, oMailPassword, oMailAuthType, oMailArchiveFolder) oPollResult = FetchMessages(oMailServer, oMailPortIn, oMailUser, oMailPassword, oMailAuthType, oMailArchiveFolder)
Case Else Case Else
Logger.Error("Poll Type [{0}] is not supported!", CURRENT_POLL_TYPE) _Logger.Error("Poll Type [{0}] is not supported!", CURRENT_POLL_TYPE)
oPollResult = False oPollResult = False
End Select End Select
End If End If
If CURRENT_WORKMAIL_UID_LIST.Count() > 0 Or LocalEmail = True Then If CURRENT_WORKMAIL_UID_LIST.Count() > 0 Or LocalEmail = True Then
If LocalEmail Then If LocalEmail Then
Logger.Info("Working with local Mail") _Logger.Info("Working with local Mail")
Dim oEmail As IMail = New MailBuilder().CreateFromEmlFile(LocalEmlFile) Dim oEmail As IMail = New MailBuilder().CreateFromEmlFile(LocalEmlFile)
Dim oUID = String.Concat(Now.Month.ToString, Now.Day, Now.Hour, Now.Minute, Now.Second) Dim oUID = String.Concat(Now.Month.ToString, Now.Day, Now.Hour, Now.Minute, Now.Second)
ClassWorkMail.WorkEmailMessage(oEmail, oUID, oValidationSql) _ClassWorkMail.WorkEmailMessage(oEmail, oUID, oValidationSql)
'CURRENT_MAIL_MESSAGE = Nothing
Else Else
Try Try
Logger.Info(String.Format("Pulled: [{0}] E-Mails", CURRENT_WORKMAIL_UID_LIST.Count())) _Logger.Info(String.Format("Pulled: [{0}] E-Mails", CURRENT_WORKMAIL_UID_LIST.Count()))
For Each oMailId In CURRENT_WORKMAIL_UID_LIST For Each oMailId In CURRENT_WORKMAIL_UID_LIST
Dim oEmail As IMail = Fetcher.FetchMail(oMailId) Dim oEmail As IMail = _Fetcher.FetchMail(oMailId)
If Not IsNothing(oEmail) Then If Not IsNothing(oEmail) Then
If EmailLimitationEnabled Then If EmailLimitationEnabled Then
@ -220,52 +212,51 @@ Public Class clsWorker
oEmailFrom = m.Address oEmailFrom = m.Address
Next Next
If oEmailFrom <> EmailLimitationSender Then If oEmailFrom <> EmailLimitationSender Then
Logger.Debug($"Skipping email {oEmailFrom} ...Subject [{oEmail.Subject}]") _Logger.Debug($"Skipping email {oEmailFrom} ...Subject [{oEmail.Subject}]")
Continue For Continue For
End If End If
End If End If
If ClassWorkMail.WorkEmailMessage(oEmail, oMailId, oValidationSql) = True Then ' Hier wird die einzelne EMail jetzt verarbeitet
If _ClassWorkMail.WorkEmailMessage(oEmail, oMailId, oValidationSql) = True Then
If LocalEmlFile = "" Then If LocalEmlFile = "" Then
DeleteOrMoveEmailFile(oMailId) DeleteOrMoveEmailFile(oMailId)
End If End If
End If End If
Else Else
Logger.Info("### oEmail was nothing ###") _Logger.Info("### oEmail was nothing ###")
End If End If
'CURRENT_MAIL_MESSAGE = Nothing
Next Next
If CURRENT_POLL_TYPE = "IMAP" And CURRENT_WORKMAIL_UID_LIST.Count > 0 Then If CURRENT_POLL_TYPE = "IMAP" And CURRENT_WORKMAIL_UID_LIST.Count > 0 Then
Fetcher.Disconnect() _Fetcher.Disconnect()
End If End If
Catch ex As Exception Catch ex As Exception
Logger.Error(ex) _Logger.Error(ex)
Logger.Warn($"Unexpected Error working CURRENT_WORKMAIL_UID_LIST: {ex.Message} ") _Logger.Warn($"Unexpected Error working CURRENT_WORKMAIL_UID_LIST: {ex.Message} ")
End Try End Try
End If End If
Else Else
Logger.Debug(String.Format("No emails for profile!")) _Logger.Debug(String.Format("No emails for profile!"))
End If End If
Else Else
Logger.Warn("For the Email-Profile ID " & CURRENT_EMAIL_GUID & " no record could be found!") _Logger.Warn("For the Email-Profile ID " & CURRENT_EMAIL_GUID & " no record could be found!")
End If End If
Database.ExecuteNonQuery("UPDATE TBEMLP_POLL_PROFILES SET LAST_TICK = GETDATE() WHERE GUID = " & oProfile.Item("GUID").ToString) _Database.ExecuteNonQuery("UPDATE TBEMLP_POLL_PROFILES SET LAST_TICK = GETDATE() WHERE GUID = " & oProfile.Item("GUID").ToString)
Else Else
Logger.Warn("For the Email-Profile ID " & CURRENT_EMAIL_GUID & " no record could be found! Check wether Email-Profile is active!") _Logger.Warn("For the Email-Profile ID " & CURRENT_EMAIL_GUID & " no record could be found! Check wether Email-Profile is active!")
End If End If
Next Next
DeleteTempFiles() DeleteTempFiles()
Database.ExecuteNonQuery("UPDATE TBEMLP_CONFIG SET LAST_TICK = GETDATE() WHERE GUID = 1") _Database.ExecuteNonQuery("UPDATE TBEMLP_CONFIG SET LAST_TICK = GETDATE() WHERE GUID = 1")
Catch ex As Exception Catch ex As Exception
Logger.Error(ex) _Logger.Error(ex)
End Try End Try
End Sub End Sub
@ -277,9 +268,9 @@ Public Class clsWorker
Dim oClientId As String = pServer Dim oClientId As String = pServer
Dim oClientSecret As String = pPassword Dim oClientSecret As String = pPassword
Dim oTenantId As String = pArchiveFolder Dim oTenantId As String = pArchiveFolder
oSession = Fetcher.ConnectToO365(pUsername, oClientId, oTenantId, oClientSecret) oSession = _Fetcher.ConnectToO365(pUsername, oClientId, oTenantId, oClientSecret)
Else Else
oSession = Fetcher.Connect(pServer, pPort, pUsername, pPassword, pAuthType, New MailSession.MailSessionOptions() With { oSession = _Fetcher.Connect(pServer, pPort, pUsername, pPassword, pAuthType, New MailSession.MailSessionOptions() With {
.EnableTls1_1 = True, .EnableTls1_1 = True,
.EnableTls1_2 = True .EnableTls1_2 = True
}) })
@ -287,25 +278,25 @@ Public Class clsWorker
If oSession.Connected = False AndAlso oSession.Error IsNot Nothing Then If oSession.Connected = False AndAlso oSession.Error IsNot Nothing Then
Logger.Warn("Connection to Mail Server failed!") _Logger.Warn("Connection to Mail Server failed!")
Logger.Error(oSession.Error) _Logger.Error(oSession.Error)
Return False Return False
ElseIf oSession.Connected = False Then ElseIf oSession.Connected = False Then
Logger.Warn("Connection to Mail Server failed!") _Logger.Warn("Connection to Mail Server failed!")
Return False Return False
End If End If
CURRENT_ImapObject = Fetcher.Client CURRENT_ImapObject = _Fetcher.Client
Dim oMailIds As List(Of Long) = Fetcher.ListAllMails() Dim oMailIds As List(Of Long) = _Fetcher.ListAllMails()
If oMailIds Is Nothing Then If oMailIds Is Nothing Then
Logger.Warn("List of UIDs was Nothing. Exiting.") _Logger.Warn("List of UIDs was Nothing. Exiting.")
Return False Return False
End If End If
If oMailIds.Count = 0 Then If oMailIds.Count = 0 Then
Logger.Debug("No Emails found.") _Logger.Debug("No Emails found.")
Return True Return True
End If End If
@ -314,7 +305,7 @@ Public Class clsWorker
Return True Return True
Catch ex As Exception Catch ex As Exception
Logger.Error(ex) _Logger.Error(ex)
Return False Return False
End Try End Try
@ -322,41 +313,41 @@ Public Class clsWorker
Private Sub DeleteOrMoveEmailFile(pMailId As Integer) Private Sub DeleteOrMoveEmailFile(pMailId As Integer)
Try Try
If MESSAGE_ERROR = True Then If MESSAGE_ERROR = True Then
Logger.Warn("Did not delete or move Message with UID [{0}] as there was an MessageError!", pMailId) _Logger.Warn("Did not delete or move Message with UID [{0}] as there was an MessageError!", pMailId)
Return Return
End If End If
If IsNothing(Fetcher.Client) Then If IsNothing(_Fetcher.Client) Then
Logger.Warn("Did not delete or move Message with UID [{0}] as ImapClient is null", pMailId) _Logger.Warn("Did not delete or move Message with UID [{0}] as ImapClient is null", pMailId)
Return Return
End If End If
If DeleteMail = True Then If DeleteMail = True Then
Fetcher.Client.DeleteMessageByUID(pMailId) _Fetcher.Client.DeleteMessageByUID(pMailId)
Logger.Info("Email with Id [{0}] was deleted.", pMailId) _Logger.Info("Email with Id [{0}] was deleted.", pMailId)
Else Else
If TestImapFolderExists(SUCCESS_IMAP_FOLDER) Then If TestImapFolderExists(SUCCESS_IMAP_FOLDER) Then
If Fetcher.Client.MoveByUID(pMailId, SUCCESS_IMAP_FOLDER) IsNot Nothing Then If _Fetcher.Client.MoveByUID(pMailId, SUCCESS_IMAP_FOLDER) IsNot Nothing Then
Logger.Info("Email with UID [{0}] was moved", pMailId) _Logger.Info("Email with UID [{0}] was moved", pMailId)
End If End If
Else Else
Logger.Warn("IMAP Folder [{0}] does not exist. Emails could not be moved!", SUCCESS_IMAP_FOLDER) _Logger.Warn("IMAP Folder [{0}] does not exist. Emails could not be moved!", SUCCESS_IMAP_FOLDER)
End If End If
End If End If
Catch ex As Exception Catch ex As Exception
Logger.Error(ex) _Logger.Error(ex)
End Try End Try
End Sub End Sub
Private Function TestImapFolderExists(pFolderName As String) As Boolean Private Function TestImapFolderExists(pFolderName As String) As Boolean
Try Try
Return Fetcher.Client. Return _Fetcher.Client.
GetFolders(). GetFolders().
Where(Function(f) f.Name = pFolderName). Where(Function(f) f.Name = pFolderName).
Any() Any()
Catch ex As Exception Catch ex As Exception
Logger.Warn("Could not get IMAP folders. Returning False.") _Logger.Warn("Could not get IMAP folders. Returning False.")
Logger.Error(ex) _Logger.Error(ex)
Return False Return False
End Try End Try
End Function End Function

View File

@ -13,7 +13,7 @@ Public Class MyService
Private LogConfig As LogConfig Private LogConfig As LogConfig
Private Logger As Logger Private Logger As Logger
Private EmailWorker As clsWorkEmail 'Private EmailWorker As clsWorkEmail
Private _DBConfig As ClassDBConfig.Config Private _DBConfig As ClassDBConfig.Config
@ -55,8 +55,9 @@ Public Class MyService
Logger.Warn("Error while initializing DBConfig") Logger.Warn("Error while initializing DBConfig")
End If End If
EmailWorker = New clsWorkEmail(LogConfig, _ConfigData.ConnectionString, _DBConfig.WindreamConnectionString, _ConfigData) ' MP 10.01.25 - Das Objekt wird hier gar nicht weiter verwendet. erstmal raus damit
Logger.Debug("Module Workmail initialized") 'EmailWorker = New clsWorkEmail(LogConfig, _ConfigData.ConnectionString, _DBConfig.WindreamConnectionString, _ConfigData)
'Logger.Debug("Module Workmail initialized")
If Database.DBInitialized = False Then If Database.DBInitialized = False Then
Logger.Warn("No Connection was established! Exiting.") Logger.Warn("No Connection was established! Exiting.")
@ -100,7 +101,7 @@ Public Class MyService
_DBConfig.WindreamConnectionString, _DBConfig.WindreamConnectionString,
oProfileIdForPolling, oProfileIdForPolling,
_ConfigData) _ConfigData)
oWorker.Start_WorkingProfiles(False, True) oWorker.Start_WorkingProfiles(False)
Catch ex As Exception Catch ex As Exception
Logger.Error(ex) Logger.Error(ex)
End Try End Try

View File

@ -1,6 +1,6 @@
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1 Partial Class Form1
Inherits System.Windows.Forms.Form Inherits DevExpress.XtraBars.Ribbon.RibbonForm
'Das Formular überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen. 'Das Formular überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen.
<System.Diagnostics.DebuggerNonUserCode()> _ <System.Diagnostics.DebuggerNonUserCode()> _
@ -22,34 +22,41 @@ Partial Class Form1
'Das Bearbeiten mit dem Code-Editor ist nicht möglich. 'Das Bearbeiten mit dem Code-Editor ist nicht möglich.
<System.Diagnostics.DebuggerStepThrough()> _ <System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent() Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Form1)) Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Form1))
Me.RibbonControl1 = New DevExpress.XtraBars.Ribbon.RibbonControl() Me.RibbonControl1 = New DevExpress.XtraBars.Ribbon.RibbonControl()
Me.BarButtonItem1 = New DevExpress.XtraBars.BarButtonItem() Me.BarButtonItem1 = New DevExpress.XtraBars.BarButtonItem()
Me.bsifolderbrowser = New DevExpress.XtraBars.BarStaticItem() Me.bsifolderbrowser = New DevExpress.XtraBars.BarStaticItem()
Me.BarButtonItem2 = New DevExpress.XtraBars.BarButtonItem() Me.btRunEmailCheck = New DevExpress.XtraBars.BarButtonItem()
Me.BarButtonItem3 = New DevExpress.XtraBars.BarButtonItem() Me.BarButtonItem3 = New DevExpress.XtraBars.BarButtonItem()
Me.bsitemppath = New DevExpress.XtraBars.BarStaticItem() Me.bsitemppath = New DevExpress.XtraBars.BarStaticItem()
Me.RibbonPage1 = New DevExpress.XtraBars.Ribbon.RibbonPage() Me.BarButtonItem4 = New DevExpress.XtraBars.BarButtonItem()
Me.btExtractMailAttachments = New DevExpress.XtraBars.BarButtonItem()
Me.rpPage1 = New DevExpress.XtraBars.Ribbon.RibbonPage()
Me.RibbonPageGroup1 = New DevExpress.XtraBars.Ribbon.RibbonPageGroup() Me.RibbonPageGroup1 = New DevExpress.XtraBars.Ribbon.RibbonPageGroup()
Me.RibbonPageGroup2 = New DevExpress.XtraBars.Ribbon.RibbonPageGroup() Me.RibbonPageGroup2 = New DevExpress.XtraBars.Ribbon.RibbonPageGroup()
Me.RibbonPageGroup3 = New DevExpress.XtraBars.Ribbon.RibbonPageGroup()
Me.RibbonPageGroup4 = New DevExpress.XtraBars.Ribbon.RibbonPageGroup()
Me.RibbonStatusBar1 = New DevExpress.XtraBars.Ribbon.RibbonStatusBar() Me.RibbonStatusBar1 = New DevExpress.XtraBars.Ribbon.RibbonStatusBar()
Me.FolderBrowserDialog1 = New System.Windows.Forms.FolderBrowserDialog() Me.FolderBrowserDialog1 = New System.Windows.Forms.FolderBrowserDialog()
Me.ListBox1 = New System.Windows.Forms.ListBox() Me.ListBox1 = New System.Windows.Forms.ListBox()
Me.RibbonPageGroup3 = New DevExpress.XtraBars.Ribbon.RibbonPageGroup()
Me.BarButtonItem4 = New DevExpress.XtraBars.BarButtonItem()
Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog() Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog()
Me.OpenFileDialog2 = New System.Windows.Forms.OpenFileDialog()
Me.OpenFileDialog3 = New System.Windows.Forms.OpenFileDialog()
Me.BehaviorManager1 = New DevExpress.Utils.Behaviors.BehaviorManager(Me.components)
CType(Me.RibbonControl1, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.RibbonControl1, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.BehaviorManager1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout() Me.SuspendLayout()
' '
'RibbonControl1 'RibbonControl1
' '
Me.RibbonControl1.ExpandCollapseItem.Id = 0 Me.RibbonControl1.ExpandCollapseItem.Id = 0
Me.RibbonControl1.Items.AddRange(New DevExpress.XtraBars.BarItem() {Me.RibbonControl1.ExpandCollapseItem, Me.RibbonControl1.SearchEditItem, Me.BarButtonItem1, Me.bsifolderbrowser, Me.BarButtonItem2, Me.BarButtonItem3, Me.bsitemppath, Me.BarButtonItem4}) Me.RibbonControl1.Items.AddRange(New DevExpress.XtraBars.BarItem() {Me.RibbonControl1.ExpandCollapseItem, Me.RibbonControl1.SearchEditItem, Me.BarButtonItem1, Me.bsifolderbrowser, Me.btRunEmailCheck, Me.BarButtonItem3, Me.bsitemppath, Me.BarButtonItem4, Me.btExtractMailAttachments})
Me.RibbonControl1.Location = New System.Drawing.Point(0, 0) Me.RibbonControl1.Location = New System.Drawing.Point(0, 0)
Me.RibbonControl1.MaxItemId = 7 Me.RibbonControl1.MaxItemId = 8
Me.RibbonControl1.Name = "RibbonControl1" Me.RibbonControl1.Name = "RibbonControl1"
Me.RibbonControl1.Pages.AddRange(New DevExpress.XtraBars.Ribbon.RibbonPage() {Me.RibbonPage1}) Me.RibbonControl1.Pages.AddRange(New DevExpress.XtraBars.Ribbon.RibbonPage() {Me.rpPage1})
Me.RibbonControl1.Size = New System.Drawing.Size(800, 150) Me.RibbonControl1.Size = New System.Drawing.Size(800, 158)
Me.RibbonControl1.StatusBar = Me.RibbonStatusBar1 Me.RibbonControl1.StatusBar = Me.RibbonStatusBar1
' '
'BarButtonItem1 'BarButtonItem1
@ -67,12 +74,12 @@ Partial Class Form1
Me.bsifolderbrowser.Name = "bsifolderbrowser" Me.bsifolderbrowser.Name = "bsifolderbrowser"
Me.bsifolderbrowser.PaintStyle = DevExpress.XtraBars.BarItemPaintStyle.CaptionGlyph Me.bsifolderbrowser.PaintStyle = DevExpress.XtraBars.BarItemPaintStyle.CaptionGlyph
' '
'BarButtonItem2 'btRunEmailCheck
' '
Me.BarButtonItem2.Caption = "Run Email_Check" Me.btRunEmailCheck.Caption = "Run Email_Check"
Me.BarButtonItem2.Id = 3 Me.btRunEmailCheck.Id = 3
Me.BarButtonItem2.ImageOptions.SvgImage = CType(resources.GetObject("BarButtonItem2.ImageOptions.SvgImage"), DevExpress.Utils.Svg.SvgImage) Me.btRunEmailCheck.ImageOptions.SvgImage = CType(resources.GetObject("btRunEmailCheck.ImageOptions.SvgImage"), DevExpress.Utils.Svg.SvgImage)
Me.BarButtonItem2.Name = "BarButtonItem2" Me.btRunEmailCheck.Name = "btRunEmailCheck"
' '
'BarButtonItem3 'BarButtonItem3
' '
@ -89,11 +96,25 @@ Partial Class Form1
Me.bsitemppath.Name = "bsitemppath" Me.bsitemppath.Name = "bsitemppath"
Me.bsitemppath.PaintStyle = DevExpress.XtraBars.BarItemPaintStyle.CaptionGlyph Me.bsitemppath.PaintStyle = DevExpress.XtraBars.BarItemPaintStyle.CaptionGlyph
' '
'RibbonPage1 'BarButtonItem4
' '
Me.RibbonPage1.Groups.AddRange(New DevExpress.XtraBars.Ribbon.RibbonPageGroup() {Me.RibbonPageGroup1, Me.RibbonPageGroup2, Me.RibbonPageGroup3}) Me.BarButtonItem4.Caption = "Extract PDF-Attachments"
Me.RibbonPage1.Name = "RibbonPage1" Me.BarButtonItem4.Id = 6
Me.RibbonPage1.Text = "RibbonPage1" Me.BarButtonItem4.ImageOptions.SvgImage = CType(resources.GetObject("BarButtonItem4.ImageOptions.SvgImage"), DevExpress.Utils.Svg.SvgImage)
Me.BarButtonItem4.Name = "BarButtonItem4"
'
'btExtractMailAttachments
'
Me.btExtractMailAttachments.Caption = "Extract Mail-Attachments"
Me.btExtractMailAttachments.Id = 7
Me.btExtractMailAttachments.ImageOptions.SvgImage = CType(resources.GetObject("btExtractMailAttachments.ImageOptions.SvgImage"), DevExpress.Utils.Svg.SvgImage)
Me.btExtractMailAttachments.Name = "btExtractMailAttachments"
'
'rpPage1
'
Me.rpPage1.Groups.AddRange(New DevExpress.XtraBars.Ribbon.RibbonPageGroup() {Me.RibbonPageGroup1, Me.RibbonPageGroup2, Me.RibbonPageGroup3, Me.RibbonPageGroup4})
Me.rpPage1.Name = "rpPage1"
Me.rpPage1.Text = "Funktionen"
' '
'RibbonPageGroup1 'RibbonPageGroup1
' '
@ -104,46 +125,55 @@ Partial Class Form1
' '
'RibbonPageGroup2 'RibbonPageGroup2
' '
Me.RibbonPageGroup2.ItemLinks.Add(Me.BarButtonItem2) Me.RibbonPageGroup2.ItemLinks.Add(Me.btRunEmailCheck)
Me.RibbonPageGroup2.Name = "RibbonPageGroup2" Me.RibbonPageGroup2.Name = "RibbonPageGroup2"
Me.RibbonPageGroup2.Text = "Run" Me.RibbonPageGroup2.Text = "Run"
' '
'RibbonStatusBar1
'
Me.RibbonStatusBar1.ItemLinks.Add(Me.bsifolderbrowser)
Me.RibbonStatusBar1.ItemLinks.Add(Me.bsitemppath)
Me.RibbonStatusBar1.Location = New System.Drawing.Point(0, 423)
Me.RibbonStatusBar1.Name = "RibbonStatusBar1"
Me.RibbonStatusBar1.Ribbon = Me.RibbonControl1
Me.RibbonStatusBar1.Size = New System.Drawing.Size(800, 27)
'
'ListBox1
'
Me.ListBox1.Dock = System.Windows.Forms.DockStyle.Fill
Me.ListBox1.FormattingEnabled = True
Me.ListBox1.Location = New System.Drawing.Point(0, 150)
Me.ListBox1.Name = "ListBox1"
Me.ListBox1.Size = New System.Drawing.Size(800, 273)
Me.ListBox1.TabIndex = 2
'
'RibbonPageGroup3 'RibbonPageGroup3
' '
Me.RibbonPageGroup3.ItemLinks.Add(Me.BarButtonItem4) Me.RibbonPageGroup3.ItemLinks.Add(Me.BarButtonItem4)
Me.RibbonPageGroup3.Name = "RibbonPageGroup3" Me.RibbonPageGroup3.Name = "RibbonPageGroup3"
Me.RibbonPageGroup3.Text = "PDF Handling" Me.RibbonPageGroup3.Text = "PDF Handling"
' '
'BarButtonItem4 'RibbonPageGroup4
' '
Me.BarButtonItem4.Caption = "Extract PDF-Attachments" Me.RibbonPageGroup4.ItemLinks.Add(Me.btExtractMailAttachments)
Me.BarButtonItem4.Id = 6 Me.RibbonPageGroup4.Name = "RibbonPageGroup4"
Me.BarButtonItem4.ImageOptions.SvgImage = CType(resources.GetObject("BarButtonItem4.ImageOptions.SvgImage"), DevExpress.Utils.Svg.SvgImage) Me.RibbonPageGroup4.Text = "EML Handling"
Me.BarButtonItem4.Name = "BarButtonItem4" '
'RibbonStatusBar1
'
Me.RibbonStatusBar1.ItemLinks.Add(Me.bsifolderbrowser)
Me.RibbonStatusBar1.ItemLinks.Add(Me.bsitemppath)
Me.RibbonStatusBar1.Location = New System.Drawing.Point(0, 426)
Me.RibbonStatusBar1.Name = "RibbonStatusBar1"
Me.RibbonStatusBar1.Ribbon = Me.RibbonControl1
Me.RibbonStatusBar1.Size = New System.Drawing.Size(800, 24)
'
'ListBox1
'
Me.ListBox1.Dock = System.Windows.Forms.DockStyle.Fill
Me.ListBox1.FormattingEnabled = True
Me.ListBox1.Location = New System.Drawing.Point(0, 158)
Me.ListBox1.Name = "ListBox1"
Me.ListBox1.Size = New System.Drawing.Size(800, 268)
Me.ListBox1.TabIndex = 2
' '
'OpenFileDialog1 'OpenFileDialog1
' '
Me.OpenFileDialog1.Filter = "PDF Files|*.pdf" Me.OpenFileDialog1.Filter = "PDF Files|*.pdf"
Me.OpenFileDialog1.InitialDirectory = "e:\" Me.OpenFileDialog1.InitialDirectory = "e:\"
' '
'OpenFileDialog2
'
Me.OpenFileDialog2.Filter = "EML Files|*.eml"
Me.OpenFileDialog2.InitialDirectory = "e:\temp"
Me.OpenFileDialog2.Title = "Wähle EML-Datei"
'
'OpenFileDialog3
'
Me.OpenFileDialog3.FileName = "OpenFileDialog3"
'
'Form1 'Form1
' '
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
@ -153,21 +183,24 @@ Partial Class Form1
Me.Controls.Add(Me.RibbonStatusBar1) Me.Controls.Add(Me.RibbonStatusBar1)
Me.Controls.Add(Me.RibbonControl1) Me.Controls.Add(Me.RibbonControl1)
Me.Name = "Form1" Me.Name = "Form1"
Me.Text = "Form1" Me.Ribbon = Me.RibbonControl1
Me.StatusBar = Me.RibbonStatusBar1
Me.Text = "EMail Profiler - Test Tool"
CType(Me.RibbonControl1, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.RibbonControl1, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.BehaviorManager1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False) Me.ResumeLayout(False)
Me.PerformLayout() Me.PerformLayout()
End Sub End Sub
Friend WithEvents RibbonControl1 As DevExpress.XtraBars.Ribbon.RibbonControl Friend WithEvents RibbonControl1 As DevExpress.XtraBars.Ribbon.RibbonControl
Friend WithEvents RibbonPage1 As DevExpress.XtraBars.Ribbon.RibbonPage Friend WithEvents rpPage1 As DevExpress.XtraBars.Ribbon.RibbonPage
Friend WithEvents RibbonPageGroup1 As DevExpress.XtraBars.Ribbon.RibbonPageGroup Friend WithEvents RibbonPageGroup1 As DevExpress.XtraBars.Ribbon.RibbonPageGroup
Friend WithEvents BarButtonItem1 As DevExpress.XtraBars.BarButtonItem Friend WithEvents BarButtonItem1 As DevExpress.XtraBars.BarButtonItem
Friend WithEvents RibbonStatusBar1 As DevExpress.XtraBars.Ribbon.RibbonStatusBar Friend WithEvents RibbonStatusBar1 As DevExpress.XtraBars.Ribbon.RibbonStatusBar
Friend WithEvents FolderBrowserDialog1 As FolderBrowserDialog Friend WithEvents FolderBrowserDialog1 As FolderBrowserDialog
Friend WithEvents bsifolderbrowser As DevExpress.XtraBars.BarStaticItem Friend WithEvents bsifolderbrowser As DevExpress.XtraBars.BarStaticItem
Friend WithEvents BarButtonItem2 As DevExpress.XtraBars.BarButtonItem Friend WithEvents btRunEmailCheck As DevExpress.XtraBars.BarButtonItem
Friend WithEvents BarButtonItem3 As DevExpress.XtraBars.BarButtonItem Friend WithEvents BarButtonItem3 As DevExpress.XtraBars.BarButtonItem
Friend WithEvents RibbonPageGroup2 As DevExpress.XtraBars.Ribbon.RibbonPageGroup Friend WithEvents RibbonPageGroup2 As DevExpress.XtraBars.Ribbon.RibbonPageGroup
Friend WithEvents ListBox1 As ListBox Friend WithEvents ListBox1 As ListBox
@ -175,4 +208,9 @@ Partial Class Form1
Friend WithEvents BarButtonItem4 As DevExpress.XtraBars.BarButtonItem Friend WithEvents BarButtonItem4 As DevExpress.XtraBars.BarButtonItem
Friend WithEvents RibbonPageGroup3 As DevExpress.XtraBars.Ribbon.RibbonPageGroup Friend WithEvents RibbonPageGroup3 As DevExpress.XtraBars.Ribbon.RibbonPageGroup
Friend WithEvents OpenFileDialog1 As OpenFileDialog Friend WithEvents OpenFileDialog1 As OpenFileDialog
Friend WithEvents btExtractMailAttachments As DevExpress.XtraBars.BarButtonItem
Friend WithEvents RibbonPageGroup4 As DevExpress.XtraBars.Ribbon.RibbonPageGroup
Friend WithEvents OpenFileDialog2 As OpenFileDialog
Friend WithEvents OpenFileDialog3 As OpenFileDialog
Friend WithEvents BehaviorManager1 As DevExpress.Utils.Behaviors.BehaviorManager
End Class End Class

View File

@ -154,7 +154,7 @@
NC43QzMyLjEsMTQuMywzMS44LDE0LDMxLjMsMTR6IiBjbGFzcz0iWWVsbG93IiAvPg0KPC9zdmc+Cw== NC43QzMyLjEsMTQuMywzMS44LDE0LDMxLjMsMTR6IiBjbGFzcz0iWWVsbG93IiAvPg0KPC9zdmc+Cw==
</value> </value>
</data> </data>
<data name="BarButtonItem2.ImageOptions.SvgImage" type="DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v21.2" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="btRunEmailCheck.ImageOptions.SvgImage" type="DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v21.2" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value> <value>
AAEAAAD/////AQAAAAAAAAAMAgAAAFlEZXZFeHByZXNzLkRhdGEudjIxLjIsIFZlcnNpb249MjEuMi40 AAEAAAD/////AQAAAAAAAAAMAgAAAFlEZXZFeHByZXNzLkRhdGEudjIxLjIsIFZlcnNpb249MjEuMi40
LjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjg4ZDE3NTRkNzAwZTQ5YQUBAAAAHURl LjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjg4ZDE3NTRkNzAwZTQ5YQUBAAAAHURl
@ -227,6 +227,25 @@
MywzdjE2YzAsMC42LTAuNCwxLTEsMXMtMS0wLjQtMS0xVjEwaC0ydjEzICAgYzAsMS43LDEuMywzLDMs MywzdjE2YzAsMC42LTAuNCwxLTEsMXMtMS0wLjQtMS0xVjEwaC0ydjEzICAgYzAsMS43LDEuMywzLDMs
M3MzLTEuMywzLTNWN2MwLTIuOC0yLjItNS01LTVzLTUsMi4yLTUsNXYxNmMwLDMuOSwzLjEsNyw3LDdz M3MzLTEuMywzLTNWN2MwLTIuOC0yLjItNS01LTVzLTUsMi4yLTUsNXYxNmMwLDMuOSwzLjEsNyw3LDdz
Ny0zLjEsNy03VjEwSDIyeiIgY2xhc3M9IkJsYWNrIiAvPg0KICA8L2c+DQo8L3N2Zz4L Ny0zLjEsNy03VjEwSDIyeiIgY2xhc3M9IkJsYWNrIiAvPg0KICA8L2c+DQo8L3N2Zz4L
</value>
</data>
<data name="btExtractMailAttachments.ImageOptions.SvgImage" type="DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v21.2" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAEAAAD/////AQAAAAAAAAAMAgAAAFlEZXZFeHByZXNzLkRhdGEudjIxLjIsIFZlcnNpb249MjEuMi40
LjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjg4ZDE3NTRkNzAwZTQ5YQUBAAAAHURl
dkV4cHJlc3MuVXRpbHMuU3ZnLlN2Z0ltYWdlAQAAAAREYXRhBwICAAAACQMAAAAPAwAAAKQCAAAC77u/
PD94bWwgdmVyc2lvbj0nMS4wJyBlbmNvZGluZz0nVVRGLTgnPz4NCjxzdmcgeD0iMHB4IiB5PSIwcHgi
IHZpZXdCb3g9IjAgMCAzMiAzMiIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcv
MjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4bWw6c3Bh
Y2U9InByZXNlcnZlIiBpZD0iTGF5ZXJfMSIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAg
MzIgMzIiPg0KICA8c3R5bGUgdHlwZT0idGV4dC9jc3MiPgoJLkJsYWNre2ZpbGw6IzcyNzI3Mjt9Cgku
WWVsbG93e2ZpbGw6I0ZGQjExNTt9CgkuQmx1ZXtmaWxsOiMxMTc3RDc7fQoJLlJlZHtmaWxsOiNEMTFD
MUM7fQoJLldoaXRle2ZpbGw6I0ZGRkZGRjt9CgkuR3JlZW57ZmlsbDojMDM5QzIzO30KCS5zdDB7Zmls
bDojNzI3MjcyO30KCS5zdDF7b3BhY2l0eTowLjU7fQoJLnN0MntvcGFjaXR5OjAuNzU7fQo8L3N0eWxl
Pg0KICA8ZyBpZD0iTWFpbCI+DQogICAgPHBhdGggZD0iTTE2LDE4LjNsMTQtOFYyNWMwLDAuNS0wLjUs
MS0xLDFIM2MtMC41LDAtMS0wLjUtMS0xVjEwLjNMMTYsMTguM3ogTTI5LDZIM0MyLjUsNiwyLDYuNSwy
LDd2MWwxNCw4bDE0LThWNyAgIEMzMCw2LjUsMjkuNSw2LDI5LDZ6IiBjbGFzcz0iQmxhY2siIC8+DQog
IDwvZz4NCjwvc3ZnPgs=
</value> </value>
</data> </data>
<metadata name="FolderBrowserDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="FolderBrowserDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
@ -235,4 +254,13 @@
<metadata name="OpenFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="OpenFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>186, 17</value> <value>186, 17</value>
</metadata> </metadata>
<metadata name="OpenFileDialog2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>327, 17</value>
</metadata>
<metadata name="OpenFileDialog3.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>468, 17</value>
</metadata>
<metadata name="BehaviorManager1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>609, 17</value>
</metadata>
</root> </root>

View File

@ -1,8 +1,10 @@
Imports System.IO Imports System.IO
Imports System.Text.RegularExpressions Imports System.Text.RegularExpressions
Imports DevExpress.Data.Helpers.ExpressiveSortInfo
Imports DigitalData.Modules.Config Imports DigitalData.Modules.Config
Imports DigitalData.Modules.Database Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Logging Imports DigitalData.Modules.Logging
Imports EmailProfiler.Common
Imports GdPicture14 Imports GdPicture14
Imports Independentsoft.Email.Mime Imports Independentsoft.Email.Mime
Imports Attachment = Independentsoft.Email.Mime.Attachment Imports Attachment = Independentsoft.Email.Mime.Attachment
@ -13,6 +15,7 @@ Public Class Form1
Private Shared _MyLogger As LogConfig Private Shared _MyLogger As LogConfig
Private _Worklist As List(Of String) Private _Worklist As List(Of String)
Private MyDatabase As MSSQLServer Private MyDatabase As MSSQLServer
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
Try Try
_MyLogger = New LogConfig(LogConfig.PathType.CustomPath, Path.Combine(My.Application.Info.DirectoryPath, "Log"), Nothing, My.Application.Info.CompanyName, My.Application.Info.ProductName) _MyLogger = New LogConfig(LogConfig.PathType.CustomPath, Path.Combine(My.Application.Info.DirectoryPath, "Log"), Nothing, My.Application.Info.CompanyName, My.Application.Info.ProductName)
@ -64,7 +67,8 @@ Public Class Form1
End If End If
End Sub End Sub
Private Sub BarButtonItem2_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem2.ItemClick Private Sub btRunEmailCheck_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btRunEmailCheck.ItemClick
' Check Email
ListBox1.Items.Clear() ListBox1.Items.Clear()
Dim di As New DirectoryInfo(bsifolderbrowser.Caption) Dim di As New DirectoryInfo(bsifolderbrowser.Caption)
' Get a reference to each file in that directory. ' Get a reference to each file in that directory.
@ -132,7 +136,7 @@ Public Class Form1
oString = " ## Attachment NOT EXISTING ##" oString = " ## Attachment NOT EXISTING ##"
_logger.Info(oString) _logger.Info(oString)
ListBox1.Items.Add(oString) ListBox1.Items.Add(oString)
If System.IO.File.Exists(oAttachmentFileString) = False Then If File.Exists(oAttachmentFileString) = False Then
_logger.Debug(String.Format("Trying to save attachment [{0}]", oAttachmentFileString)) _logger.Debug(String.Format("Trying to save attachment [{0}]", oAttachmentFileString))
Try Try
oAttachment.Save(oAttachmentFileString) oAttachment.Save(oAttachmentFileString)
@ -190,7 +194,7 @@ Public Class Form1
End Try End Try
End Function End Function
Private Sub BarButtonItem4_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem4.ItemClick Private Sub btExtractPdfAttachments_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem4.ItemClick
' FileOpen Dialog ' FileOpen Dialog
Dim fileOpenDlg = OpenFileDialog1 Dim fileOpenDlg = OpenFileDialog1
@ -268,4 +272,33 @@ Public Class Form1
End Try End Try
End Sub End Sub
Private Sub btExtractMailAttachments_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btExtractMailAttachments.ItemClick
' Hier verarbeiten wir eine ausgewählte EML-Datei
' und speichern alle Anhänge auf die Platte.
' Der Einstieg und der Ablauf entspricht dem des Services.
' Unterschied ist die lokale Datei
Dim connectionString As String = "Server=SDD-VMP04-SQL17\DD_DEVELOP01;Database=DD_ECM;User Id=sa;Password=dd"
Dim oConfigData As ConfigData = New ConfigData() With {
.Debug = False,
.GDPictureVersion = "11.2024",
.UseWindream = False,
.ConnectionString = connectionString
}
Dim Worker As ExtractAttachmentsFromEMLFile = New ExtractAttachmentsFromEMLFile()
' FileOpen Dialog
Dim fileOpenDlg = OpenFileDialog2
If fileOpenDlg.ShowDialog() = DialogResult.OK Then
Dim oFilename = fileOpenDlg.FileName
' Call Extract Method
Worker.CallWorkerProcess(oFilename, oConfigData)
End If
End Sub
End Class End Class

View File

@ -0,0 +1,30 @@
Imports System.IO
Imports DigitalData.Modules.Logging
Imports EmailProfiler.Common
Public Class ExtractAttachmentsFromEMLFile
Private ReadOnly _LogConfig As LogConfig
Sub New()
Dim oLogPath = Path.Combine(My.Application.Info.DirectoryPath, "Log")
_LogConfig = New LogConfig(LogConfig.PathType.CustomPath, oLogPath, Nothing, "Digital Data", "DD EmailProfiler TEST", 30)
End Sub
Public Sub CallWorkerProcess(pEMLFilename As String, pConfigData As ConfigData)
Dim oProfileIdForPolling = 0
Dim oWorker As New clsWorker(_LogConfig,
pConfigData.ConnectionString,
"",
oProfileIdForPolling,
pConfigData,
pEMLFilename)
oWorker.Start_WorkingProfiles(True)
End Sub
End Class

View File

@ -71,6 +71,9 @@
<Reference Include="Independentsoft.Email"> <Reference Include="Independentsoft.Email">
<HintPath>P:\Projekte DIGITAL DATA\DIGITAL DATA - Entwicklung\DLL_Bibliotheken\Email .NET\Bin\Independentsoft.Email.dll</HintPath> <HintPath>P:\Projekte DIGITAL DATA\DIGITAL DATA - Entwicklung\DLL_Bibliotheken\Email .NET\Bin\Independentsoft.Email.dll</HintPath>
</Reference> </Reference>
<Reference Include="Mail">
<HintPath>P:\Visual Studio Projekte\Bibliotheken\Limilabs\Mail.dll\Mail.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
<Reference Include="NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL"> <Reference Include="NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.5.0.5\lib\net46\NLog.dll</HintPath> <HintPath>..\packages\NLog.5.0.5\lib\net46\NLog.dll</HintPath>
@ -105,6 +108,7 @@
<Import Include="System.Threading.Tasks" /> <Import Include="System.Threading.Tasks" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="TestClasses\ExtractAttachmentsFromEMLFile.vb" />
<Compile Include="Form1.vb"> <Compile Include="Form1.vb">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
@ -154,6 +158,12 @@
<None Include="App.config" /> <None Include="App.config" />
<None Include="packages.config" /> <None Include="packages.config" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ProjectReference Include="..\EmailProfiler.Common\EmailProfiler.Common.vbproj">
<Project>{9F748DCD-952E-40A0-9DAD-65BF8A39B231}</Project>
<Name>EmailProfiler.Common</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
<Import Project="..\packages\GdPicture.runtimes.windows.14.2.90\build\net462\GdPicture.runtimes.windows.targets" Condition="Exists('..\packages\GdPicture.runtimes.windows.14.2.90\build\net462\GdPicture.runtimes.windows.targets')" /> <Import Project="..\packages\GdPicture.runtimes.windows.14.2.90\build\net462\GdPicture.runtimes.windows.targets" Condition="Exists('..\packages\GdPicture.runtimes.windows.14.2.90\build\net462\GdPicture.runtimes.windows.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">