diff --git a/App/.vs/SERV_EMAIL/v16/.suo b/App/.vs/SERV_EMAIL/v16/.suo index b79ca81..d30215f 100644 Binary files a/App/.vs/SERV_EMAIL/v16/.suo and b/App/.vs/SERV_EMAIL/v16/.suo differ diff --git a/App/CONFIG_APP/obj/Debug/DesignTimeResolveAssemblyReferences.cache b/App/CONFIG_APP/obj/Debug/DesignTimeResolveAssemblyReferences.cache index ec7e2a7..cb6daac 100644 Binary files a/App/CONFIG_APP/obj/Debug/DesignTimeResolveAssemblyReferences.cache and b/App/CONFIG_APP/obj/Debug/DesignTimeResolveAssemblyReferences.cache differ diff --git a/App/DigitalData.EMLProfiler/My Project/AssemblyInfo.vb b/App/DigitalData.EMLProfiler/My Project/AssemblyInfo.vb index 008b8d1..7ec22f7 100644 --- a/App/DigitalData.EMLProfiler/My Project/AssemblyInfo.vb +++ b/App/DigitalData.EMLProfiler/My Project/AssemblyInfo.vb @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices ' übernehmen, indem Sie "*" eingeben: ' - - + + diff --git a/App/DigitalData.EMLProfiler/bin/Debug/DigitalData.EMLProfiler.dll b/App/DigitalData.EMLProfiler/bin/Debug/DigitalData.EMLProfiler.dll index c43f36b..23fd278 100644 Binary files a/App/DigitalData.EMLProfiler/bin/Debug/DigitalData.EMLProfiler.dll and b/App/DigitalData.EMLProfiler/bin/Debug/DigitalData.EMLProfiler.dll differ diff --git a/App/DigitalData.EMLProfiler/bin/Debug/DigitalData.EMLProfiler.pdb b/App/DigitalData.EMLProfiler/bin/Debug/DigitalData.EMLProfiler.pdb index 2831dde..9494cd2 100644 Binary files a/App/DigitalData.EMLProfiler/bin/Debug/DigitalData.EMLProfiler.pdb and b/App/DigitalData.EMLProfiler/bin/Debug/DigitalData.EMLProfiler.pdb differ diff --git a/App/DigitalData.EMLProfiler/bin/Debug/DigitalData.Modules.Database.dll b/App/DigitalData.EMLProfiler/bin/Debug/DigitalData.Modules.Database.dll index 70affe1..936a8d1 100644 Binary files a/App/DigitalData.EMLProfiler/bin/Debug/DigitalData.Modules.Database.dll and b/App/DigitalData.EMLProfiler/bin/Debug/DigitalData.Modules.Database.dll differ diff --git a/App/DigitalData.EMLProfiler/bin/Debug/DigitalData.Modules.Database.pdb b/App/DigitalData.EMLProfiler/bin/Debug/DigitalData.Modules.Database.pdb index 28c1227..ae69c73 100644 Binary files a/App/DigitalData.EMLProfiler/bin/Debug/DigitalData.Modules.Database.pdb and b/App/DigitalData.EMLProfiler/bin/Debug/DigitalData.Modules.Database.pdb differ diff --git a/App/DigitalData.EMLProfiler/bin/Debug/DigitalData.Modules.Logging.dll b/App/DigitalData.EMLProfiler/bin/Debug/DigitalData.Modules.Logging.dll index 567bf2f..659d413 100644 Binary files a/App/DigitalData.EMLProfiler/bin/Debug/DigitalData.Modules.Logging.dll and b/App/DigitalData.EMLProfiler/bin/Debug/DigitalData.Modules.Logging.dll differ diff --git a/App/DigitalData.EMLProfiler/bin/Debug/DigitalData.Modules.Logging.pdb b/App/DigitalData.EMLProfiler/bin/Debug/DigitalData.Modules.Logging.pdb index 89b6035..4e44d1c 100644 Binary files a/App/DigitalData.EMLProfiler/bin/Debug/DigitalData.Modules.Logging.pdb and b/App/DigitalData.EMLProfiler/bin/Debug/DigitalData.Modules.Logging.pdb differ diff --git a/App/DigitalData.EMLProfiler/clsEmail.IMAP.vb b/App/DigitalData.EMLProfiler/clsEmail.IMAP.vb index 4601eab..2971dd0 100644 --- a/App/DigitalData.EMLProfiler/clsEmail.IMAP.vb +++ b/App/DigitalData.EMLProfiler/clsEmail.IMAP.vb @@ -23,87 +23,105 @@ Public Class clsEmailIMAP 'End Sub Public Function FetchIMAPMessages(Server As String, Port As Integer, Username As String, Password As String, pInbox As String, Optional IsTest As Boolean = False, Optional DeleteinTest As Boolean = False, Optional MoveMailTo As String = "") As Boolean - Logger.Debug("S22 Connecting to Server {0}:{1} with user {2}", Server, Port, Username) + Logger.Debug("S22FetchIMAPMessages - Connecting to Server {0}:{1} with user {2}", Server, Port, Username) Try - Logger.Debug("S22 Connecting...") + Logger.Debug("S22FetchIMAPMessages - Connecting...") Using oClient As New S22.Imap.ImapClient(Server, Port, Username, Password, S22.Imap.AuthMethod.Login, True) If Not oClient.Authed Then - Logger.Warn("S22 Connected to server but authentication failed.") + Logger.Warn("S22FetchIMAPMessages - Connected to server but authentication failed.") Return False End If - Logger.Debug($"S22 Fetching unseen MessageIds from Inbox: {pInbox}") + Logger.Debug($"S22FetchIMAPMessages - Fetching unseen MessageIds from Inbox: {pInbox}") Dim oMessageIds As IEnumerable(Of UInteger) = oClient.Search(S22.Imap.SearchCondition.Unseen, pInbox) - Logger.Debug("S22 Found {0} messages", oMessageIds.Count) - Logger.Debug("S22 Fetching messages...") + Logger.Debug("S22FetchIMAPMessages - Found {0} messages", oMessageIds.Count) + Logger.Debug("S22FetchIMAPMessages - Fetching messages...") Dim oMessageCountRegular As Integer = 0 Dim oMessageCountWorked As Integer = 0 + Dim oLastLog As String For Each oMessageId As UInteger In oMessageIds - Logger.Debug($"Checking message") + Logger.Debug($"Checking message...") Dim oMessage = oClient.GetMessage(oMessageId, False, pInbox) - Logger.Debug($"Checking message Subject: {oMessage.Subject}, From: {oMessage.From}") - + oLastLog = $"Checking message with Subject [{oMessage.Subject}] From [{oMessage.From}]" + Logger.Debug(oLastLog) Dim oTempPath = Path.GetTempFileName() - Dim oResult = WriteMessageToFile(oMessage, oTempPath) - - Dim oMsg As New Message(oTempPath) - Dim oMessageREFGUID = oMsg.MessageID - oMessageREFGUID = oMessageREFGUID.Replace(">", "").Replace("<", "") - Dim oCHECKSQL = $"SELECT * FROM TBEMLP_HISTORY WHERE lower(EMAIL_MSGID) = lower('{oMessageREFGUID}')" - Dim oCHECKDT As DataTable = _DB_MSSQL.Return_Datatable(oCHECKSQL) - If Not IsNothing(oCHECKDT) Then - If oCHECKDT.Rows.Count = 0 Then - oMessageCountRegular += 1 - CURRENT_WORKMAIL_LIST.Add(oMsg) - Else - Logger.Info("S22 Message has already been worked! Skipping!") - Logger.Debug($"Message shall be deleted...") - - oClient.DeleteMessage(oMessageId,) - Logger.Debug($"S22 Message has been deleted!") - Dim oUpd = $"UPDATE TBEMLP_HISTORY SET DATE_DELETED_INBOX = GETDATE() WHERE lower(EMAIL_MSGID) = lower('{oMessageId}')" - _DB_MSSQL.Execute_non_Query(oUpd) - oMessageCountWorked += 1 - End If - If IsTest = True Then - Logger.Debug($"S22 IMAP-Test Message#: {oMessageCountRegular} - Msgsubject is: {oMsg.Subject} - MsgMessageID is: {oMessageREFGUID}") - Logger.Debug($"S22 message correctly fetched. Mail has been downloaded to {oTempPath}") - End If - Try - If DeleteinTest = True Then - Logger.Debug($"Message shall be deleted...") - oClient.DeleteMessage(oMessageId,) - Logger.Debug($"S22 Message has been deleted!") - End If - Catch ex As Exception - Logger.Warn("Message could not be deleted: " & ex.Message) - End Try - If MoveMailTo <> String.Empty Then - Try - Logger.Debug($"Moving to [{MoveMailTo}] is active...") - oClient.MoveMessage(oMessageId, MoveMailTo) - Logger.Debug($"S22 successfully moved!") - Catch ex As Exception - Logger.Warn($"S22 Could not move message to folder [{MoveMailTo}] - Error: {ex.Message}") - End Try - End If - - - End If - Try - If IsTest = False Then - File.Delete(oTempPath) + Dim oResult = WriteMessageToFile(oMessage, oTempPath) + oLastLog &= $" # Message written to TempPath [{oTempPath}]" + Dim oMessageREFGUID + Dim oMsg As Message + Try + oLastLog &= " # Creating the New Message(oTempPath)" + oMsg = New Message(oTempPath) + oLastLog &= " # Extracting the MessageID" + oMessageREFGUID = oMsg.MessageID + Catch ex As Exception + Logger.Warn($"S22FetchIMAPMessages - Could not get a MessageID or create a MailObject - Error: {ex.Message} - Last Debug Log: [{oLastLog}]") + Continue For + End Try + + oLastLog &= " # Got the MessageID" + oMessageREFGUID = oMessageREFGUID.Replace(">", "").Replace("<", "") + Dim oCHECKSQL = $"SELECT * FROM TBEMLP_HISTORY WHERE lower(EMAIL_MSGID) = lower('{oMessageREFGUID}')" + Dim oCHECKDT As DataTable = _DB_MSSQL.Return_Datatable(oCHECKSQL) + If Not IsNothing(oCHECKDT) Then + If oCHECKDT.Rows.Count = 0 Then + oMessageCountRegular += 1 + CURRENT_WORKMAIL_LIST.Add(oMsg) + oLastLog &= " # Added to CURRENT_WORKMAIL_LIST" + Else + Logger.Info("S22FetchIMAPMessages - Message has already been worked! Skipping!") + Logger.Debug($"Message shall be deleted...") + oLastLog &= " # Message shall be deleted..." + oClient.DeleteMessage(oMessageId,) + Logger.Debug($"S22FetchIMAPMessages - Message has been deleted!") + oLastLog &= " # S22FetchIMAPMessages - Message has been deleted!" + Dim oUpd = $"UPDATE TBEMLP_HISTORY SET DATE_DELETED_INBOX = GETDATE() WHERE lower(EMAIL_MSGID) = lower('{oMessageId}')" + _DB_MSSQL.Execute_non_Query(oUpd) + oMessageCountWorked += 1 + End If + If IsTest = True Then + Logger.Debug($"S22FetchIMAPMessages - IMAP-Test Message#: {oMessageCountRegular} - Msgsubject is: {oMsg.Subject} - MsgMessageID is: {oMessageREFGUID}") + Logger.Debug($"S22FetchIMAPMessages - message correctly fetched. Mail has been downloaded to {oTempPath}") + End If + Try + If DeleteinTest = True Then + Logger.Debug($"Message shall be deleted...") + oClient.DeleteMessage(oMessageId,) + Logger.Debug($"S22FetchIMAPMessages - Message has been deleted!") + End If + Catch ex As Exception + Logger.Warn("Message could not be deleted: " & ex.Message) + End Try + If MoveMailTo <> String.Empty Then + Try + Logger.Debug($"Moving to [{MoveMailTo}] is active...") + oClient.MoveMessage(oMessageId, MoveMailTo) + Logger.Debug($"S22FetchIMAPMessages - successfully moved!") + Catch ex As Exception + Logger.Warn($"S22FetchIMAPMessages - Could not move message to folder [{MoveMailTo}] - Error: {ex.Message}") + End Try + End If + + End If + Try + If IsTest = False Then + File.Delete(oTempPath) + End If + + Catch ex As Exception + + End Try Catch ex As Exception - Logger.Error(ex) - Logger.Warn("S22 Temp file could not be deleted") + Logger.Warn($"FetchIMAPMessages - Unexpected Error while working on email: [{ex.Message}] - Last Debug Log: [{oLastLog}]") End Try + Next oClient.Expunge() - Logger.Debug("S22 Finished Message-Fetch") + Logger.Debug("S22FetchIMAPMessages - Finished Message-Fetch") If oMessageCountRegular > 0 Or oMessageCountWorked > 0 Then Logger.Info($"###############################################") If oMessageCountRegular > 0 Then diff --git a/App/DigitalData.EMLProfiler/clsWorker.vb b/App/DigitalData.EMLProfiler/clsWorker.vb index 43e1cac..a53bb1b 100644 --- a/App/DigitalData.EMLProfiler/clsWorker.vb +++ b/App/DigitalData.EMLProfiler/clsWorker.vb @@ -135,10 +135,10 @@ Public Class clsWorker End If If pollresult = False Then - Logger.Warn(String.Format("Error while polling emails...Trying S22....")) + Logger.Info(String.Format("Error while polling emails...Trying S22....")) pollresult = _emailIMAP.FetchIMAPMessages(MAIL_SERVER, MAIL_PORT, MAIL_USER, MAIL_USER_PW, MAIL_INBOX_NAME) If pollresult = False Then - Logger.Warn(String.Format("S22 also returned error!")) + Logger.Warn(String.Format("S22FetchIMAPMessages - also returned error!")) End If End If If CURRENT_WORKMAIL_LIST.Count() > 0 Then diff --git a/App/DigitalData.EMLProfiler/obj/Debug/DigitalData.EMLProfiler.dll b/App/DigitalData.EMLProfiler/obj/Debug/DigitalData.EMLProfiler.dll index c43f36b..23fd278 100644 Binary files a/App/DigitalData.EMLProfiler/obj/Debug/DigitalData.EMLProfiler.dll and b/App/DigitalData.EMLProfiler/obj/Debug/DigitalData.EMLProfiler.dll differ diff --git a/App/DigitalData.EMLProfiler/obj/Debug/DigitalData.EMLProfiler.pdb b/App/DigitalData.EMLProfiler/obj/Debug/DigitalData.EMLProfiler.pdb index 2831dde..9494cd2 100644 Binary files a/App/DigitalData.EMLProfiler/obj/Debug/DigitalData.EMLProfiler.pdb and b/App/DigitalData.EMLProfiler/obj/Debug/DigitalData.EMLProfiler.pdb differ diff --git a/App/SERV_EMAIL/obj/Debug/DesignTimeResolveAssemblyReferences.cache b/App/SERV_EMAIL/obj/Debug/DesignTimeResolveAssemblyReferences.cache index d4c16b8..90f08ef 100644 Binary files a/App/SERV_EMAIL/obj/Debug/DesignTimeResolveAssemblyReferences.cache and b/App/SERV_EMAIL/obj/Debug/DesignTimeResolveAssemblyReferences.cache differ