This commit is contained in:
2020-08-10 17:28:32 +02:00
parent fbb4d8ad2e
commit d49e627f5d
89 changed files with 1832 additions and 1250 deletions

View File

@@ -2,7 +2,6 @@
Imports WINDREAMLib
Public Class ClassCurrent
Public Shared LOG_ERRORS_ONLY As Boolean = True
Public Shared WM_CON_STRING As String
Public Shared WM_DRIVE As String
Public Shared TIMER_INTERVALL As Integer = 5
@@ -25,11 +24,12 @@ Public Class ClassCurrent
Public Shared MAIL_USER_PW As String = ""
Public Shared MAIL_PORT As Integer = 995
Public Shared MAIL_INBOX_NAME As String = "Inbox"
Public Shared MAIL_ARCHIVE_FOLDER As String = ""
Public Shared DT_POLL_PROCESS As DataTable
Public Shared DT_STEPS As DataTable
Public Shared DT_INDEXING_STEPS As DataTable
Public Shared MAIL_LIST As New ArrayList()
Public Shared CURRENT_WORKMAIL_LIST As New ArrayList()
Public Shared CURRENT_MAIL_MESSAGE As Message
Public Shared CURRENT_TEMP_MAIL_PATH As String

View File

@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben:
' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("2.1.0.0")>
<Assembly: AssemblyFileVersion("1.0.0.0")>
<Assembly: AssemblyVersion("2.5.0.0")>
<Assembly: AssemblyFileVersion("2.5.0.0")>

View File

@@ -206,26 +206,11 @@ DigitalData.Modules.Database
<param name="SqlCommand">sqlcommand for datatable (select XYZ from TableORView)</param>
<returns>Returns a datatable</returns>
</member>
<member name="M:DigitalData.Modules.Database.MSSQLServer.NewExecutenonQuery(System.String)">
<summary>
Executes the passed sql-statement
</summary>
<param name="executeStatement">the sql statement</param>
<returns>Returns true if properly executed, else false</returns>
<remarks></remarks>
</member>
<member name="M:DigitalData.Modules.Database.MSSQLServer.NewExecuteScalar(System.String)">
<summary>
Executes the passed sql-statement as Scalar
</summary>
<param name="ScalarSQL">the sql statement</param>
<returns>Returns true if properly executed, else false</returns>
</member>
<member name="M:DigitalData.Modules.Database.MSSQLServer.NewExecuteNonQueryAsync(System.String,System.Int32)">
<summary>
Executes the passed sql-statement in asyncmode
</summary>
<param name="executeStatement">the sql statement</param>
<param name="SqlCommand">the sql statement</param>
<param name="commandtimeout">Optional Timeout</param>
<remarks></remarks>
</member>

View File

@@ -34,33 +34,6 @@ DigitalData.Modules.Logging
<dependencies>
NLog, >= 4.5.8
</dependencies>
<params>
logPath, PathType
The basepath to write logs to. Can be AppData, CurrentDirectory or CustomPath.
- AppData: writes to local application data directory
- CurrentDirectory: writes to `Log` directory relative to the current directory
- CustomPath: writes to custom path specified in `customLogPath`
customLogPath, String (optional)
If `logPath` is set to custom, this defines the custom logPath.
suffix, String (optional)
If set to anything other than Nothing, extends the logfile name with this suffix.
</params>
<props>
LogFile, String (readonly)
Returns the full path of the default log file.
LogPath, String (readonly)
Returns the path to the log directory.
LogFactory, NLog.LogFactory (readonly)
Returns the LogFactory that is used to create the Logger object
Debug, Boolean
Determines if the debug log should be written.
</props>
<example>
Imports DigitalData.Modules.Logging
@@ -132,13 +105,15 @@ DigitalData.Modules.Logging
</summary>
<returns>A list of log messages</returns>
</member>
<member name="M:DigitalData.Modules.Logging.LogConfig.#ctor(DigitalData.Modules.Logging.LogConfig.PathType,System.String,System.String)">
<member name="M:DigitalData.Modules.Logging.LogConfig.#ctor(DigitalData.Modules.Logging.LogConfig.PathType,System.String,System.String,System.String,System.String)">
<summary>
Initializes a new LogConfig object with a logpath and optinally a filename-suffix.
</summary>
<param name="logPath">The basepath to write logs to. Can be AppData, CurrentDirectory or CustomPath.</param>
<param name="customLogPath">If `logPath` is set to custom, this defines the custom logPath.</param>
<param name="suffix">If set to anything other than Nothing, extends the logfile name with this suffix.</param>
<param name="LogPath">The basepath to write logs to. Can be AppData, CurrentDirectory or CustomPath.</param>
<param name="CustomLogPath">If `logPath` is set to custom, this defines the custom logPath.</param>
<param name="Suffix">If set to anything other than Nothing, extends the logfile name with this suffix.</param>
<param name="CompanyName">CompanyName is used to construct log-path in when LogPath is set to PathType:AppData</param>
<param name="ProductName">ProductName is used to construct log-path in when LogPath is set to PathType:AppData</param>
</member>
<member name="M:DigitalData.Modules.Logging.LogConfig.GetLogger">
<summary>

View File

@@ -21,7 +21,6 @@ Public Class clsDatabase
DTCONFIG = Return_Datatable("select * from TBEMLP_CONFIG")
If Not IsNothing(DTCONFIG) Then
If DTCONFIG.Rows.Count = 1 Then
LOG_ERRORS_ONLY = DTCONFIG.Rows(0).Item("LOG_ERRORS_ONLY")
PATH_TEMP = DTCONFIG.Rows(0).Item("PATH_EMAIL_TEMP")
PATH_ERROR = DTCONFIG.Rows(0).Item("PATH_EMAIL_ERRORS")
MAIL_BODY_FONT = DTCONFIG.Rows(0).Item("FONT_BODY")
@@ -29,7 +28,6 @@ Public Class clsDatabase
TIMER_INTERVALL = DTCONFIG.Rows(0).Item("CHECK_INTERVALL_MINUTES")
End If
End If
MyLogger.Debug = Not LOG_ERRORS_ONLY
DT_ECM_BASE_CONFIG = Return_Datatable("select * from TBDD_BASECONFIG")
Try
WM_DRIVE = DT_ECM_BASE_CONFIG.Rows(0).Item("WM_DRIVE")

View File

@@ -7,75 +7,91 @@ Imports AE
Imports System.Net
Imports System.Reflection
Imports System.IO
Imports DigitalData.Modules.Database
Public Class clsEmailIMAP
Private Shared Logger As DigitalData.Modules.Logging.Logger
Private Shared LogConfig As DigitalData.Modules.Logging.LogConfig
Sub New(LogConf As LogConfig)
Private _DB_MSSQL As clsDatabase
Sub New(LogConf As LogConfig, ECMConnectionString As String)
LogConfig = LogConf
Logger = LogConf.GetLogger
_DB_MSSQL = New clsDatabase(LogConf, ECMConnectionString)
End Sub
'Private Shared Sub OnWriteLog(ByVal sender As Object, ByVal e As WriteLogEventArgs)
' Logger.Info(e.Log)
'End Sub
Public Function FetchIMAPMessages(Server As String, Port As Integer, Username As String, Password As String, Inbox As String, Optional IsTest As Boolean = False, Optional DeleteinTest As Boolean = False, Optional MoveMailTo As String = "") As Boolean
Logger.Debug("Connecting to Server {0}:{1} with user {2}", Server, Port, Username)
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)
Try
Logger.Debug("Connecting...")
Logger.Debug("S22 Connecting...")
Using oClient As New S22.Imap.ImapClient(Server, Port, Username, Password, S22.Imap.AuthMethod.Login, True)
If Not oClient.Authed Then
Logger.Warn("Connected to server but authentication failed.")
Logger.Warn("S22 Connected to server but authentication failed.")
Return False
End If
Logger.Debug("Connection successful")
Logger.Debug($"Fetching unseen MessageIds from Inbox: {Inbox}")
Dim oMessageIds As IEnumerable(Of UInteger) = oClient.Search(S22.Imap.SearchCondition.Unseen, Inbox)
Logger.Debug("Found {0} messages", oMessageIds.Count)
Logger.Debug("Fetching messages...")
Logger.Debug($"S22 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...")
Dim oMessageCountRegular As Integer = 0
Dim oMessageCountWorked As Integer = 0
For Each oMessageId As UInteger In oMessageIds
Logger.Debug($"Checking message")
Dim oMessage = oClient.GetMessage(oMessageId, False, Inbox)
Dim oMessage = oClient.GetMessage(oMessageId, False, pInbox)
Logger.Debug($"Checking message Subject: {oMessage.Subject}, From: {oMessage.From}")
Dim oTempPath = Path.GetTempFileName()
Dim oResult = WriteMessageToFile(oMessage, oTempPath)
Dim oCount As Integer = 0
Dim oMsg As New Message(oTempPath)
oCount &= 1
If IsTest = False Then
MAIL_LIST.Add(oMsg)
Else
Logger.Debug($"IMAP-Test Message#: {oCount} - Msgsubject is: {oMsg.Subject} - MsgMessageID is: {oMsg.MessageID}")
Logger.Debug($"message correctly fetched. Mail has been downloaded to {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 DeleteinTest = True Then
Logger.Debug($"Message shall be deleted...")
oClient.DeleteMessage(oMessageId,)
Logger.Debug($"Message has been deleted!")
End If
Catch ex As Exception
Logger.Warn("Message could not be deleted: " & ex.Message)
End Try
Try
If MoveMailTo <> "" Then
Logger.Debug($"Moving to [{MoveMailTo}] is active...")
oClient.MoveMessage(oMessageId, MoveMailTo)
Logger.Debug($"Successfully moved!")
End If
Catch ex As Exception
Logger.Warn("Message could not be moved: " & ex.Message)
End Try
Try
If IsTest = False Then
File.Delete(oTempPath)
@@ -83,11 +99,35 @@ Public Class clsEmailIMAP
Catch ex As Exception
Logger.Error(ex)
Logger.Warn("Temp file could not be deleted")
Logger.Warn("S22 Temp file could not be deleted")
End Try
Next
oClient.Expunge()
Logger.Debug("Finished Message-Fetch")
Logger.Debug("S22 Finished Message-Fetch")
If oMessageCountRegular > 0 Or oMessageCountWorked > 0 Then
Logger.Info($"###############################################")
If oMessageCountRegular > 0 Then
Logger.Info($"Found [{oMessageCountRegular.ToString}] regular messages to work on!")
End If
If oMessageCountWorked > 0 Then
Logger.Info($"Found [{oMessageCountWorked.ToString}] worked messages to work on!")
End If
If IsTest = True Then
Dim omsgtext As String
If oMessageCountRegular > 0 Then
omsgtext = $"Found [{oMessageCountRegular.ToString}] regular Messages to work on!"
End If
If oMessageCountWorked > 0 Then
If omsgtext = String.Empty Then
Logger.Info($"Found [{oMessageCountWorked.ToString}] worked messages to work on!")
Else
omsgtext += vbNewLine & $"Found [{oMessageCountWorked.ToString}] worked messages to work on!"
End If
End If
MsgBox(omsgtext)
End If
Logger.Info($"###############################################")
End If
End Using
Return True
Catch ex As Exception
@@ -98,7 +138,7 @@ Public Class clsEmailIMAP
Private Shared Sub OnWriteLog(ByVal sender As Object, ByVal e As WriteLogEventArgs)
Logger.Debug(e.Log)
End Sub
Public Function FetchIMAPMessagesIsoft(Server As String, Port As Integer, Username As String, Password As String, Inbox As String, Optional IsTest As Boolean = False, Optional DeleteinTest As Boolean = False, Optional MoveMailTo As String = "", Optional IsoftLog As String = "")
Public Function FetchIMAPMessagesIsoft(Server As String, Port As Integer, Username As String, Password As String, Inbox As String, Optional MoveMailTo As String = "", Optional IsoftLog As String = "", Optional IsTest As Boolean = False, Optional DeleteinTest As Boolean = False)
Try
Logger.Debug(String.Format("Working on IMAP_COLLECT Independentsoft..."))
Dim oClient As New Independentsoft.Email.Imap.ImapClient(Server, Port)
@@ -110,7 +150,13 @@ Public Class clsEmailIMAP
oClient.EnableSsl = True
oClient.ValidateRemoteCertificate = False
oClient.Connect()
Try
oClient.Connect()
Catch ex As Exception
Logger.Warn("Error while oClient.Connec(): " & ex.Message)
Return False
End Try
Try
oClient.Login(Username, Password, AuthenticationType.Login)
Catch ex As Exception
@@ -127,49 +173,88 @@ Public Class clsEmailIMAP
oClient.SelectFolder(Inbox)
Dim coSearchCriteria As New SearchCriteria()
coSearchCriteria.Unseen = True
Dim oCount As Integer = 0
coSearchCriteria.All = True
Dim oMessageCountRegular As Integer = 0
Dim oMessageCountWorked As Integer = 0
Dim oUniqueID As Integer() = oClient.Search(coSearchCriteria)
If IsTest = True Then
MsgBox($"{oUniqueID.Count} unseen messages! (oUniqueID.Length: {oUniqueID.Length.ToString})")
Dim oFoundMessages1 As Message() = New Message(oUniqueID.Length - 1) {}
For i As Integer = 0 To oUniqueID.Length - 1
oFoundMessages1(i) = oClient.GetMessage(oUniqueID(i))
MsgBox($"Message {i.ToString} - {oFoundMessages1(i).Subject}...")
Next
MsgBox($"{oUniqueID.Count} messages in Postbox! (oUniqueID.Length: {oUniqueID.Length.ToString})")
End If
Dim oFoundMessages As Message() = New Message(oUniqueID.Length - 1) {}
Dim oEnvelopes As Independentsoft.Email.Imap.Envelope() = oClient.ListMessages()
For oCounterEnvelope As Integer = 0 To oEnvelopes.Length - 1
For oCounterUnseen As Integer = 0 To oUniqueID.Length - 1
If oEnvelopes(oCounterEnvelope).UniqueID = oUniqueID(oCounterUnseen) Then
Dim oMSG = $"Working on unseen email: UniqueID [{oEnvelopes(oCounterEnvelope).UniqueID}] - Subject[{oEnvelopes(oCounterEnvelope).Subject}] - Date [{oEnvelopes(oCounterEnvelope).Date.ToString}]"
If IsTest = True Then
MsgBox(oMSG)
End If
Logger.Info(oMSG)
Logger.Debug(oMSG)
Dim oMessage As Mime.Message = oClient.GetMessage(oEnvelopes(oCounterEnvelope).UniqueID)
If Not IsNothing(oMessage) Then
oCount += 1
MAIL_LIST.Add(oMessage)
oClient.Store(oEnvelopes(oCounterEnvelope).UniqueID, "+FLAGS", "SEEN")
For oCounterEmailInPostbox As Integer = 0 To oUniqueID.Length - 1
If oEnvelopes(oCounterEnvelope).UniqueID = oUniqueID(oCounterEmailInPostbox) Then
Dim oMimeMessage As Mime.Message = oClient.GetMessage(oEnvelopes(oCounterEnvelope).UniqueID)
If Not IsNothing(oMimeMessage) Then
Dim oMessageID = oMimeMessage.MessageID
oMessageID = oMessageID.Replace(">", "").Replace("<", "")
'oEnvelopes(oCounterEnvelope).UniqueI
Logger.Debug($"Isoft: Working on email: MessageID [{oMessageID}] - Subject[{oEnvelopes(oCounterEnvelope).Subject}] - Date [{oEnvelopes(oCounterEnvelope).Date.ToString}]")
Dim oCHECKSQL = $"SELECT * FROM TBEMLP_HISTORY WHERE lower(EMAIL_MSGID) = lower('{oMessageID}')"
Dim oCHECKDT As DataTable = _DB_MSSQL.Return_Datatable(oCHECKSQL)
If Not IsNothing(oCHECKDT) Then
If oCHECKDT.Rows.Count = 0 Then
Logger.Info($"Isoft: Adding email: MessageID [{oMessageID}] - Subject[{oEnvelopes(oCounterEnvelope).Subject}] - Date [{oEnvelopes(oCounterEnvelope).Date.ToString}]")
oMessageCountRegular += 1
CURRENT_WORKMAIL_LIST.Add(oMimeMessage)
Else
Logger.Info($"Isoft: Already existing email with MessageID [{oMessageID}] - Subject[{oEnvelopes(oCounterEnvelope).Subject}] - Date [{oEnvelopes(oCounterEnvelope).Date.ToString}] ")
oMessageCountWorked += 1
Try
oClient.Delete(oEnvelopes(oCounterEnvelope).UniqueID)
Dim oUpd = $"UPDATE TBEMLP_HISTORY SET DATE_DELETED_INBOX = GETDATE(), COMMENT = 'DELETED MESSAGE FROM INBOX (2ndRun ALREADY WORKED)' WHERE lower(EMAIL_MSGID) = lower('{oMessageID}')"
_DB_MSSQL.Execute_non_Query(oUpd)
Catch ex As Exception
Logger.Warn($"Error deleting/Commentign message due to to already worked: {ex.Message}")
End Try
End If
oClient.Store(oEnvelopes(oCounterEnvelope).UniqueID, "+FLAGS", "SEEN")
If MoveMailTo <> String.Empty Then
Try
oClient.AddMessage(MoveMailTo, oMimeMessage)
Catch ex As Exception
Logger.Warn($"Isoft: Could not move message to folder [{MoveMailTo}] - Error: {ex.Message}")
End Try
End If
End If
End If
End If
Next
Next
oClient.Expunge()
oClient.Disconnect()
If oCount > 0 Then
Logger.Debug($"###############################################")
Logger.Debug($"Found [{oCount.ToString}] Messages to work on!")
Logger.Debug($"###############################################")
If oMessageCountRegular > 0 Or oMessageCountWorked > 0 Then
Logger.Info($"###############################################")
If oMessageCountRegular > 0 Then
Logger.Info($"Isoft: Found [{oMessageCountRegular.ToString}] regular messages to work on!")
End If
If oMessageCountWorked > 0 Then
Logger.Info($"Isoft: Found [{oMessageCountWorked.ToString}] worked messages to work on!")
End If
If IsTest = True Then
Dim omsgtext As String
If oMessageCountRegular > 0 Then
omsgtext = $"Isoft: Found [{oMessageCountRegular.ToString}] regular Messages to work on!"
End If
If oMessageCountWorked > 0 Then
If omsgtext = String.Empty Then
Logger.Info($"Isoft: Found [{oMessageCountWorked.ToString}] worked messages to work on!")
Else
omsgtext += vbNewLine & $"Isoft: Found [{oMessageCountWorked.ToString}] worked messages to work on!"
End If
End If
MsgBox(omsgtext)
End If
Logger.Info($"###############################################")
End If
' Logger.Debug($"{oCount.ToString} messages will be worked..")
Logger.Debug("IMAP COLLECT Independentsoft finished!")
Logger.Debug("Isoft: IMAP COLLECT Independentsoft finished!")
Return True
Catch ex As Exception
Logger.Error(ex, "Unexpected Error in IMAP COLLECT Independentsoft:")

View File

@@ -32,14 +32,14 @@ Public Class clsEmail
Dim oMessage As Message = oClient.GetMessage(oMessageInfo(i).Index)
Dim oMsgId_AlreadyExists As Boolean = False
For Each pulled_msg As Message In MAIL_LIST
For Each pulled_msg As Message In CURRENT_WORKMAIL_LIST
If pulled_msg.MessageID = oMessage.MessageID Then
oMsgId_AlreadyExists = True
End If
Next
If oMsgId_AlreadyExists = False Then
oCOUNT += 1
MAIL_LIST.Add(oMessage)
CURRENT_WORKMAIL_LIST.Add(oMessage)
Logger.Debug(String.Format("Message [{0}] added to working Mail_List", oMessage.Subject))
End If

View File

@@ -70,7 +70,7 @@ Public Class clsWorkEmail
Logger.Info(String.Format("No relation configured for this email - Subject[{0}]", CURRENT_MAIL_SUBJECT))
COMMON_EMAIL_IN()
End If
INSERT_HISTORY()
INSERT_HISTORY_MSSQL()
End If
End If
@@ -195,7 +195,7 @@ Public Class clsWorkEmail
If Directory.Exists(oTempPath) = False Then
Directory.CreateDirectory(oTempPath)
Else
Logger.Debug($"oTempPath [{oTempPath}] is already existing!!")
Logger.Debug($"SAVE2TEMP - oTempPath [{oTempPath}] is already existing!!")
End If
Dim oFileEntries As String() = Directory.GetFiles(oTempPath)
' Process the list of files found in the directory.
@@ -266,7 +266,7 @@ Public Class clsWorkEmail
CURRENT_MAIL_MESSAGE.Save(cleanPath, True)
Logger.Info($"Email saved to ({cleanPath})")
Else
Logger.Info("EMail (" & CURRENT_MAIL_MESSAGE.Subject & ") already existing!", False, "RUN_THREAD.COPY_2_HDD")
Logger.Info("COPY2HDD - EMail (" & CURRENT_MAIL_MESSAGE.Subject & ") already existing!", False, "RUN_THREAD.COPY_2_HDD")
End If
End If
@@ -462,29 +462,51 @@ Public Class clsWorkEmail
oMSGID = oMSGID.Replace(">", "").Replace("<", "")
For Each oAttachment As Attachment In oCurrentMail.GetAttachments
Dim oATTFilename = oAttachment.GetFileName.ToString.ToLower
If Not oATTFilename.EndsWith("pdf") Then
Dim oValidExt As Boolean = False
If oATTFilename.EndsWith("pdf") Then
oValidExt = True
ElseIf oATTFilename.EndsWith("xls") Then
oValidExt = True
ElseIf oATTFilename.EndsWith("xlsx") Then
oValidExt = True
ElseIf oATTFilename.EndsWith("doc") Then
oValidExt = True
ElseIf oATTFilename.EndsWith("docx") Then
oValidExt = True
ElseIf oATTFilename.EndsWith("ppt") Then
oValidExt = True
ElseIf oATTFilename.EndsWith("pptx") Then
oValidExt = True
End If
If oValidExt = False Then
Logger.Debug(String.Format("Invalid FileExtension [{0}]", oATTFilename))
Continue For
End If
Dim oAttachmentFileString
Logger.Debug(String.Format(" Working on Attachment [{0}]", oAttachment.GetFileName))
Try
Dim oFilename = oAttachment.GetFileName
oFilename = CleanInput(oFilename)
Logger.Debug($"oFilename [{oFilename}]")
If oFilename = String.Empty Then
oFilename = oAttachment.GetFileName
End If
oAttachmentFileString = Path.Combine(PATH_TEMP, $"{oMSGID}~{oFilename}")
Logger.Debug($"oAttachmentFileString [{oAttachmentFileString}]")
If System.IO.File.Exists(oAttachmentFileString) = False Then
Logger.Debug(String.Format("Trying to save attachment [{0}]", oAttachmentFileString))
oAttachment.Save(oAttachmentFileString)
Logger.Info(String.Format("Attachment saved to [{0}]", oAttachmentFileString))
INSERT_HISTORY_FB(oMSGID, oAttachment.GetFileName)
INSERT_HISTORY_MSSQL(oMSGID, oAttachment.GetFileName)
Try
oAttachment.Save(oAttachmentFileString)
Logger.Info(String.Format("Attachment saved to [{0}]", oAttachmentFileString))
INSERT_HISTORY_FB(oMSGID, oAttachment.GetFileName)
INSERT_HISTORY_ATTMT_MSSQL(oMSGID, oAttachment.GetFileName)
Catch ex As Exception
Logger.Warn($"Error while saving attachment-name: {ex.Message} - AttachmentName: {oAttachmentFileString}")
MessageError = True
End Try
Else
Logger.Info("Attachment (" & oAttachmentFileString & ") already existing!", False, "EXTRACT_ATTACHMENTS")
Logger.Info("EXATTMNT - Attachment (" & oAttachmentFileString & ") already existing!", False, "EXTRACT_ATTACHMENTS")
End If
Catch ex As Exception
@@ -530,7 +552,7 @@ Public Class clsWorkEmail
End Function
Private Function INSERT_HISTORY()
Private Function INSERT_HISTORY_MSSQL()
If MessageError = False Then
Dim ins = $"INSERT INTO TBEMLP_HISTORY (WORK_PROCESS,EMAIL_MSGID,EMAIL_SUBJECT,EMAIL_DATE,EMAIL_BODY,EMAIL_SUBSTRING1,EMAIL_SUBSTRING2,EMAIL_FROM) VALUES " &
$"('{CURRENT_MAIL_PROCESS_NAME}'," &
@@ -542,36 +564,55 @@ Public Class clsWorkEmail
$"'{CURRENT_MAIL_BODY_Substr2}'," &
$"'{CURRENT_MAIL_FROM}')"
_DB_MSSQL.Execute_non_Query(ins)
Else
Logger.Info("! No INSERT_HISTORY as MessageError = True")
End If
End Function
Private Function INSERT_HISTORY_FB(oGUID As String, ATTMT1 As String)
If MessageError = False Then
Dim ins = $"INSERT INTO TBEDM_EMAIL_PROFILER_HISTORY (WORK_PROCESS,EMAIL_MSGID,EMAIL_FROM,EMAIL_SUBJECT,EMAIL_DATETIME,EMAIL_BODY,EMAIL_SUBSTRING1,EMAIL_SUBSTRING2,EMAIL_ATTMT1) VALUES " &
$"('{CURRENT_MAIL_PROCESS_NAME}'," &
$"'{oGUID}'," &
$"'{CURRENT_MAIL_MESSAGE.From.EmailAddress}'," &
$"'{CURRENT_MAIL_MESSAGE.Subject}'," &
$"'{CURRENT_MAIL_MESSAGE.Date}'," &
$"'{CURRENT_MAIL_BODY_ALL}'," &
$"'{CURRENT_MAIL_BODY_ANSWER1}'," &
$"'{CURRENT_MAIL_BODY_Substr2}'," &
$"'{ATTMT1}')"
_firebird.ExecuteNonQuery(ins)
If IsNothing(_firebird) Then
Logger.Info("INSERT_HISTORY_FB: _firebird is nothing ")
Return False
End If
Try
If MessageError = False Then
Dim ins = $"INSERT INTO TBEDM_EMAIL_PROFILER_HISTORY (WORK_PROCESS,EMAIL_MSGID,EMAIL_FROM,EMAIL_SUBJECT,EMAIL_DATETIME,EMAIL_BODY,EMAIL_SUBSTRING1,EMAIL_SUBSTRING2,EMAIL_ATTMT1) VALUES " &
$"('{CURRENT_MAIL_PROCESS_NAME}'," &
$"'{oGUID}'," &
$"'{CURRENT_MAIL_MESSAGE.From.EmailAddress}'," &
$"'{CURRENT_MAIL_MESSAGE.Subject}'," &
$"'{CURRENT_MAIL_MESSAGE.Date}'," &
$"'{CURRENT_MAIL_BODY_ALL}'," &
$"'{CURRENT_MAIL_BODY_ANSWER1}'," &
$"'{CURRENT_MAIL_BODY_Substr2}'," &
$"'{ATTMT1}')"
_firebird.ExecuteNonQuery(ins)
End If
Catch ex As Exception
Logger.Error(ex)
End Try
End Function
Private Function INSERT_HISTORY_MSSQL(oMSGID As String, ATTMT1 As String)
If MessageError = False Then
Dim ins = $"INSERT INTO TBEMLP_HISTORY_ATTACHMENT (WORK_PROCESS,EMAIL_MSGID,EMAIL_FROM,EMAIL_SUBJECT,EMAIL_DATETIME,EMAIL_BODY,EMAIL_ATTMT) VALUES " &
$"('{CURRENT_MAIL_PROCESS_NAME}'," &
$"'{oMSGID}'," &
$"'{CURRENT_MAIL_MESSAGE.From.EmailAddress}'," &
$"'{CURRENT_MAIL_MESSAGE.Subject}'," &
$"'{CURRENT_MAIL_MESSAGE.Date}'," &
$"'{CURRENT_MAIL_BODY_ALL}'," &
$"'{ATTMT1}')"
_DB_MSSQL.Execute_non_Query(ins)
Private Function INSERT_HISTORY_ATTMT_MSSQL(oMSGID As String, ATTMT1 As String)
If IsNothing(_DB_MSSQL) Then
Logger.Info("INSERT_HISTORY_FB: _DB_MSSQL is nothing ")
Return False
End If
Try
If MessageError = False Then
Dim ins = $"INSERT INTO TBEMLP_HISTORY_ATTACHMENT (WORK_PROCESS,EMAIL_MSGID,EMAIL_FROM,EMAIL_SUBJECT,EMAIL_DATETIME,EMAIL_BODY,EMAIL_ATTMT) VALUES " &
$"('{CURRENT_MAIL_PROCESS_NAME}'," &
$"'{oMSGID}'," &
$"'{CURRENT_MAIL_MESSAGE.From.EmailAddress}'," &
$"'{CURRENT_MAIL_MESSAGE.Subject}'," &
$"'{CURRENT_MAIL_MESSAGE.Date}'," &
$"'{CURRENT_MAIL_BODY_ALL}'," &
$"'{ATTMT1}')"
_DB_MSSQL.Execute_non_Query(ins)
End If
Catch ex As Exception
Logger.Error(ex)
End Try
End Function
Private Function GetChildren(ByVal bodyParts As BodyPartCollection) As BodyPartCollection

View File

@@ -16,7 +16,7 @@ Public Class clsWorker
Sub New(LogConf As LogConfig, ConStr As String, POLL_PROFILEID As Integer, FB_DATASOURCE As String, FB_DATABASE As String, FB_USER As String, FB_PW As String, Optional localeml As String = "")
Logger = LogConf.GetLogger
_email = New clsEmail(LogConf)
_emailIMAP = New clsEmailIMAP(LogConf)
_emailIMAP = New clsEmailIMAP(LogConf, ConStr)
_Database = New clsDatabase(LogConf, ConStr)
cs = ConStr
_windream = New clsWindream_allgemein(LogConf)
@@ -101,6 +101,7 @@ Public Class clsWorker
MAIL_USER_PW = row("EMAIL_PW")
MAIL_PORT = row("PORT_IN")
MAIL_INBOX_NAME = "Inbox"
MAIL_ARCHIVE_FOLDER = row("ARCHIVE_FOLDER")
Logger.Debug(String.Format("{0}-{1}", MAIL_FROM, MAIL_SERVER))
Dim PWPlain = _wrapper.DecryptData(MAIL_USER_PW)
@@ -115,21 +116,21 @@ Public Class clsWorker
End If
Next
MAIL_LIST.Clear()
CURRENT_WORKMAIL_LIST.Clear()
If MAIL_SERVER <> "" Then
Dim pollresult As Boolean = False
If LocalEmail = True Then
pollresult = True
Dim oMessage As New Message(CURRENT_DEBUG_LOCAL_EMAIL)
MAIL_LIST.Add(oMessage)
CURRENT_WORKMAIL_LIST.Add(oMessage)
Else
Select Case CURRENT_POLL_TYPE
Case "POP"
pollresult = _email.POP3_COLLECT()
Case "IMAP"
'pollresult = _emailIMAP.IMAP_COLLECT()
pollresult = _emailIMAP.FetchIMAPMessagesIsoft(MAIL_SERVER, MAIL_PORT, MAIL_USER, MAIL_USER_PW, MAIL_INBOX_NAME)
pollresult = _emailIMAP.FetchIMAPMessagesIsoft(MAIL_SERVER, MAIL_PORT, MAIL_USER, MAIL_USER_PW, MAIL_INBOX_NAME, MAIL_ARCHIVE_FOLDER)
End Select
End If
@@ -140,15 +141,15 @@ Public Class clsWorker
Logger.Warn(String.Format("S22 also returned error!"))
End If
End If
If MAIL_LIST.Count() > 0 Then
Logger.Info(String.Format("Worked/Pulled: {0} E-Mails", MAIL_LIST.Count()))
For Each pulled_msg As Message In MAIL_LIST
If CURRENT_WORKMAIL_LIST.Count() > 0 Then
Logger.Info(String.Format("Worked/Pulled: {0} E-Mails", CURRENT_WORKMAIL_LIST.Count()))
For Each pulled_msg As Message In CURRENT_WORKMAIL_LIST
If _workmail.WORK_MAIL(pulled_msg) = True Then
End If
Next
Else
Logger.Debug(String.Format("No emails for profile!"))
Logger.Info(String.Format("No emails for profile!"))
End If
Else
Logger.Warn("For the Email-Profile ID " & CURRENT_EMAIL_GUID & " no record could be found!")
@@ -162,7 +163,9 @@ Public Class clsWorker
Try
'Delete all Tempfiles
For Each _file In TEMP_FILES
System.IO.File.Delete(_file)
If System.IO.File.Exists(_file) Then
System.IO.File.Delete(_file)
End If
Next
Try
Dim oDiTempPath As New IO.DirectoryInfo(System.IO.Path.GetTempPath)
@@ -173,17 +176,17 @@ Public Class clsWorker
Try
fi.Delete()
Catch ex As Exception
Logger.Warn($"SWP1 - Could not delete the tempfile: {ex.Message}")
Logger.Warn($"TempFileDelete2 - Could not delete the tempfile: {ex.Message}")
End Try
Next
Catch ex As Exception
Logger.Warn($"SWP2 - Could not delete the tempfile: {ex.Message}")
Logger.Warn($"TempFileDelete3 - Could not delete the tempfile: {ex.Message}")
End Try
Catch ex As Exception
Logger.Warn($"SWP - Could not delete the tempfile from TEMP_FILES: {ex.Message}")
Logger.Info($"TempFileDelete - Could not delete the tempfile from TEMP_FILES: {ex.Message}")
End Try
Else

View File

@@ -1 +0,0 @@
064839440650a653f8e769d63390527023957743

View File

@@ -23,9 +23,7 @@ E:\SchreiberM\Visual Studio\GIT\DD_EmailProfiler\App\DigitalData.EMLProfiler\bin
E:\SchreiberM\Visual Studio\GIT\DD_EmailProfiler\App\DigitalData.EMLProfiler\bin\Debug\FirebirdSql.Data.FirebirdClient.pdb
E:\SchreiberM\Visual Studio\GIT\DD_EmailProfiler\App\DigitalData.EMLProfiler\obj\Debug\DigitalData.EMLProfiler.Resources.resources
E:\SchreiberM\Visual Studio\GIT\DD_EmailProfiler\App\DigitalData.EMLProfiler\obj\Debug\DigitalData.EMLProfiler.vbproj.GenerateResource.cache
E:\SchreiberM\Visual Studio\GIT\DD_EmailProfiler\App\DigitalData.EMLProfiler\obj\Debug\DigitalData.EMLProfiler.vbproj.CoreCompileInputs.cache
E:\SchreiberM\Visual Studio\GIT\DD_EmailProfiler\App\DigitalData.EMLProfiler\obj\Debug\DigitalData.EMLProfiler.vbproj.CopyComplete
E:\SchreiberM\Visual Studio\GIT\DD_EmailProfiler\App\DigitalData.EMLProfiler\obj\Debug\DigitalData.EMLProfiler.dll
E:\SchreiberM\Visual Studio\GIT\DD_EmailProfiler\App\DigitalData.EMLProfiler\obj\Debug\DigitalData.EMLProfiler.xml
E:\SchreiberM\Visual Studio\GIT\DD_EmailProfiler\App\DigitalData.EMLProfiler\obj\Debug\DigitalData.EMLProfiler.pdb
E:\SchreiberM\Visual Studio\GIT\DD_EmailProfiler\App\DigitalData.EMLProfiler\obj\Debug\DigitalData.EMLProfiler.vbprojAssemblyReference.cache