MS Erweiterung IMAP

This commit is contained in:
Digital Data - Marlon Schreiber
2019-03-26 16:35:05 +01:00
parent 1d07465ca5
commit 9b9ec33533
98 changed files with 2215 additions and 349688 deletions

View File

@@ -5,6 +5,7 @@ Imports System.Net
Imports System.ComponentModel
Imports Independentsoft.Email
Imports Independentsoft.Email.Mime
Imports System.Text.RegularExpressions
Public Class frmMain
Private Logger As DigitalData.Modules.Logging.Logger
@@ -494,34 +495,30 @@ Public Class frmMain
Private Sub TabControl1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles TabControl1.SelectedIndexChanged
tsbtnRunProfiles.Visible = False
tslblRefresh.BackColor = Color.Transparent
tslblRefresh.Text = ""
Select Case TabControl1.SelectedIndex
Case 0
tsbtnRunProfiles.Visible = True
Case 1
Try
Dim oDTFunctionRegex As DataTable = _database.Return_Datatable("SELECT * FROM TBDD_FUNCTION_REGEX WHERE FUNCTION_NAME = 'EMAIL_PROFILER - BODY REMOVE NewLine'")
If oDTFunctionRegex.Rows.Count = 1 Then
txtRegexvbNewline.Text = oDTFunctionRegex.Rows(0).Item("REGEX")
End If
Catch ex As Exception
MsgBox("Error in Load Regex: " & vbNewLine & ex.Message, MsgBoxStyle.Critical)
End Try
Load_Config()
Case 2
Load_History()
Case 4
Try
Dim osql = "SELECT * FROM TBDD_FUNCTION_REGEX WHERE UPPER(FUNCTION_NAME) IN (UPPER('EMAIL_PROFILER - RemoveHTMLText'),UPPER('EMAIL_PROFILER - RemoveHTMLText1'))"
Dim oDTFunctionRegex As DataTable = _database.Return_Datatable(osql)
txtRegex1.Text = oDTFunctionRegex.Rows(0).Item("REGEX")
txtRegex2.Text = oDTFunctionRegex.Rows(1).Item("REGEX")
txthtmlEmail.BackColor = Color.Wheat
Catch ex As Exception
MsgBox("Error in Load Regex: " & vbNewLine & ex.Message, MsgBoxStyle.Critical)
End Try
End Select
End Sub
Private Sub btnsaveRegex_Click(sender As Object, e As EventArgs) Handles btnsaveRegex.Click
Dim upd = $"UPDATE TBDD_FUNCTION_REGEX SET REGEX = '{txtRegexvbNewline.Text}' WHERE FUNCTION_NAME = 'EMAIL_PROFILER - BODY REMOVE NewLine'"
If _database.Execute_non_Query(upd) = True Then
tslblRefresh.Text = "Regex saved - " & Now.ToString
Else
tslblRefresh.Text = "Regex NOT saved - Check Your log: " & Now.ToString
End If
End Sub
Private Sub ACTIVECheckBox_CheckedChanged(sender As Object, e As EventArgs) Handles ACTIVECheckBox.CheckedChanged
Active_Color()
End Sub
@@ -590,40 +587,6 @@ Public Class frmMain
_database.Execute_non_Query(upd)
Load_Config()
End Sub
Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs) Handles TextBox2.TextChanged
If File.Exists(TextBox2.Text) Then
Dim msg_email As New Independentsoft.Email.Mime.Message(TextBox2.Text)
Dim oTEMPBODYSTRING As String
Dim CURRENT_MAIL_BODY As String
If IsNothing(msg_email.Body) Then
Dim oAllBodyParts As New BodyPartCollection()
oAllBodyParts.Add(msg_email.BodyParts)
oAllBodyParts.Add(GetChildren(msg_email.BodyParts))
For Each bodyPart As BodyPart In oAllBodyParts
If bodyPart.ContentType IsNot Nothing AndAlso bodyPart.ContentType.Type = "text" AndAlso bodyPart.ContentType.SubType = "plain" Then
Logger.Debug(String.Format("BODY1-Text is....#{0}", bodyPart.Body))
If CURRENT_MAIL_BODY <> bodyPart.Body Then
CURRENT_MAIL_BODY = bodyPart.Body
End If
ElseIf bodyPart.ContentType IsNot Nothing AndAlso bodyPart.ContentType.Type = "text" AndAlso bodyPart.ContentType.SubType = "html" Then
Logger.Debug(String.Format("bodyhtml....#{0}", bodyPart.Body))
If CURRENT_MAIL_BODY = "" Then
CURRENT_MAIL_BODY = bodyPart.Body
Logger.Debug(String.Format("bodyhtml....#{0}", bodyPart.Body))
End If
End If
Next
Else
CURRENT_MAIL_BODY = msg_email.Body
End If
End If
End Sub
Private Function GetChildren(ByVal bodyParts As BodyPartCollection) As BodyPartCollection
Dim children As New BodyPartCollection()
@@ -674,7 +637,7 @@ Public Class frmMain
My.Settings.Save()
Dim PWPlain = _Encryption.DecryptData(EMAIL_PWTextBox.Text)
If _email.Email_Send_Independentsoft("Testmail DD Windream-ResultHandler", "This is the body (text will be replaced within profile)", txtTestmail.Text,
If _email.Email_Send_Independentsoft("Testmail", "This is the body (text will be replaced within profile)", txtTestmail.Text,
EMAIL_FROMTextBox.Text, EMAIL_SMTPTextBox.Text, PORTTextBox.Text, EMAIL_USERTextBox.Text, PWPlain, AUTH_TYPEComboBox.Text, "") = True Then
MsgBox("Email was send successfully.", MsgBoxStyle.Information)
Else
@@ -695,5 +658,129 @@ Public Class frmMain
_email.TEST_POP3_COLLECT(EMAIL_SMTPTextBox.Text, PORTTextBox.Text, EMAIL_USERTextBox.Text, PWPlain)
End Sub
Private Sub btnTestRegEx_Click(sender As Object, e As EventArgs) Handles btnTestRegEx.Click
txtResultRegEx.Text = ""
Try
My.Settings.Save()
txtResultRegEx.BackColor = Color.WhiteSmoke
' Instantiate the regular expression object.
Dim oReg As Regex = New Regex(txtRegex1.Text, RegexOptions.IgnoreCase)
Dim oMatch As Match = oReg.Match(txthtmlEmail.Text)
Dim oClearedBodyText = txthtmlEmail.Text
Do While oMatch.Success
oClearedBodyText = oClearedBodyText.Replace(oMatch.Value, "")
'Dim g As Group = m.Groups(1)
'If g.ToString.StartsWith("&") = False Then
' TEMP_HTML_RESULTS.Add(g.ToString())
'End If
oMatch = oMatch.NextMatch()
Loop
Logger.Info($"Cleared bodytext after Regex1 is: {oClearedBodyText}")
Dim oReg2 As Regex = New Regex(txtRegex2.Text, RegexOptions.IgnoreCase)
Dim oMatch2 As Match = oReg2.Match(oClearedBodyText)
Do While oMatch2.Success
oClearedBodyText = oClearedBodyText.Replace(oMatch2.Value, "")
'Dim g As Group = m.Groups(1)
'If g.ToString.StartsWith("&") = False Then
' TEMP_HTML_RESULTS.Add(g.ToString())
'End If
oMatch2 = oMatch2.NextMatch()
Loop
Logger.Info($"Cleared bodytext after Regex2 is: {oClearedBodyText}")
txtResultRegEx.Text = oClearedBodyText
txtResultRegEx.BackColor = Color.Yellow
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical)
End Try
End Sub
Private Sub btnsaveRegex_Click_1(sender As Object, e As EventArgs) Handles btnsaveRegex.Click
tslblRefresh.BackColor = Color.Transparent
Dim upd = $"UPDATE TBDD_FUNCTION_REGEX SET REGEX = '{txtRegex1.Text}' WHERE UPPER(FUNCTION_NAME) = UPPER('EMAIL_PROFILER - RemoveHTMLText')"
If _database.Execute_non_Query(upd) = True Then
tslblRefresh.Text = "Regex1 saved - " & Now.ToString
tslblRefresh.BackColor = Color.Yellow
Else
tslblRefresh.Text = "Regex1 NOT saved - Check Your log: " & Now.ToString
tslblRefresh.BackColor = Color.Transparent
End If
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Try
txthtmlEmail.Text = ""
txthtmlEmail.BackColor = Color.Wheat
Dim oOpenFileDialog1 As New OpenFileDialog()
' openFileDialog1.InitialDirectory = "c:\"
oOpenFileDialog1.Filter = "Emails (*.eml)|*.eml|All files (*.*)|*.*"
oOpenFileDialog1.FilterIndex = 2
oOpenFileDialog1.RestoreDirectory = True
If oOpenFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
Dim oMsg_email As New Independentsoft.Email.Mime.Message(oOpenFileDialog1.FileName)
Dim oBodyText As String = ""
If IsNothing(oMsg_email.Body) Then
Dim oAllBodyParts As New BodyPartCollection()
oAllBodyParts.Add(oMsg_email.BodyParts)
oAllBodyParts.Add(GetChildren(oMsg_email.BodyParts))
For Each bodyPart As BodyPart In oAllBodyParts
If bodyPart.ContentType IsNot Nothing AndAlso bodyPart.ContentType.Type = "text" AndAlso bodyPart.ContentType.SubType = "plain" Then
If oBodyText = String.Empty Then
Logger.Debug(String.Format("BODY1-Text is....#{0}", bodyPart.Body))
oBodyText = bodyPart.Body
Else
Continue For
End If
ElseIf bodyPart.ContentType IsNot Nothing AndAlso bodyPart.ContentType.Type = "text" AndAlso bodyPart.ContentType.SubType = "html" Then
If oBodyText = String.Empty Then
oBodyText = bodyPart.Body
Logger.Debug(String.Format("bodyhtml....#{0}", bodyPart.Body))
Else
Continue For
End If
Logger.Debug(String.Format("bodyhtml....#{0}", bodyPart.Body))
End If
Next
If oBodyText = "" Then
MsgBox("No html-body extractable?!")
Else
txthtmlEmail.Text = oBodyText
txthtmlEmail.BackColor = Color.Yellow
End If
Else
txthtmlEmail.Text = oMsg_email.Body
txthtmlEmail.BackColor = Color.Yellow
End If
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical)
End Try
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
tslblRefresh.BackColor = Color.Transparent
Dim upd = $"UPDATE TBDD_FUNCTION_REGEX SET REGEX = '{txtRegex2.Text}' WHERE UPPER(FUNCTION_NAME) = UPPER('EMAIL_PROFILER - RemoveHTMLText1')"
If _database.Execute_non_Query(upd) = True Then
tslblRefresh.Text = "Regex2 saved - " & Now.ToString
tslblRefresh.BackColor = Color.Yellow
Else
tslblRefresh.Text = "Regex2 NOT saved - Check Your log: " & Now.ToString
tslblRefresh.BackColor = Color.Transparent
End If
End Sub
Private Sub COPY_2_HDDCheckBox_CheckedChanged(sender As Object, e As EventArgs) Handles COPY_2_HDDCheckBox.CheckedChanged
If COPY_2_HDDCheckBox.Checked Then
PATH_ORIGINALTextBox.Enabled = True
Else
PATH_ORIGINALTextBox.Enabled = False
End If
End Sub
End Class