Compare commits

..

9 Commits

Author SHA1 Message Date
Developer01
8a0011394b Merge branch 'master' of https://vcs.digitaldata.works/AppStd/EmailProfiler 2026-06-29 16:48:54 +02:00
Developer01
fa7fa40e1f O Auth aus Oberfäche 2026-06-29 16:48:43 +02:00
743df08376 Verweise korrigiert 2026-06-25 11:33:58 +02:00
9246feee2a Verweise 2026-06-25 11:30:09 +02:00
2756c5b564 Merge branch 'master' of http://git.dd:3000/AppStd/EmailProfiler 2026-06-25 11:04:06 +02:00
Developer01
d41e8ad314 3.6 2026-06-23 11:42:42 +02:00
Developer01
a160971319 3.5.0 2026-06-23 11:41:43 +02:00
3c365361a1 EmailProfiler.Common: Version 3.5.4.0 2026-05-15 13:25:30 +02:00
deafdd90c8 EmailProfiler.Common: Logik zur Vermeidung von doppelten EMail MessageIDs überarbeitet 2026-05-15 13:24:28 +02:00
9 changed files with 236 additions and 64 deletions

View File

@@ -22,14 +22,11 @@ Public Class MailContainer
''' <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 Property MessageId As String
''' <summary> Public ReadOnly Property EMailDate As Date
''' Eine zweite MessageID, in der das Mail-Datum berücksichtigt wird.
''' Wird verwendet wenn MessageId bereits existiert. Public ReadOnly Property MessageIDHashSet As HashSet(Of String) = New HashSet(Of String)
''' </summary>
''' <returns></returns>
Public ReadOnly Property MessageId2 As String
''' <summary> ''' <summary>
''' The subject, truncated to SUBJECT_MAX_LENGTH characters ''' The subject, truncated to SUBJECT_MAX_LENGTH characters
@@ -48,13 +45,39 @@ Public Class MailContainer
MessageIdOriginal = pMail.MessageID MessageIdOriginal = pMail.MessageID
MessageId = StringEx.GetShortHash(pMail.MessageID) MessageId = StringEx.GetShortHash(pMail.MessageID)
MessageId2 = StringEx.GetShortHash(pMail.MessageID + pMail.Date.ToString())
Subject = ObjectEx.NotNull(pMail.Subject.Truncate(SUBJECT_MAX_LENGTH), String.Empty) Subject = ObjectEx.NotNull(pMail.Subject.Truncate(SUBJECT_MAX_LENGTH), String.Empty)
SubjectOriginal = ObjectEx.NotNull(pMail.Subject, String.Empty) SubjectOriginal = ObjectEx.NotNull(pMail.Subject, String.Empty)
SenderAddress = GetSenderAddress(pMail) SenderAddress = GetSenderAddress(pMail)
SenderDomain = GetSenderDomain(pMail) SenderDomain = GetSenderDomain(pMail)
EMailDate = GetEmailDate(pMail)
End Sub
''' <summary>
''' Erzeugt eine Liste von n unterschiedlichen MessageIDs
''' Dabei verwenden wir den vorherigen Wert, um daraus einen neuen zu erzeugen
''' </summary>
Public Sub InitializeHashsetOfMessageIDs()
MessageIDHashSet.Clear()
Dim nextMessageID As String
If String.IsNullOrEmpty(MessageIdOriginal) = True Then
nextMessageID = "1234567890ABCDEFGHIJKLMNOPQRSTUV" ' irgendwelche 32 Zeichen
Else
nextMessageID = MessageIdOriginal
End If
For index = 1 To 10
Dim zeitMitMs As String = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
nextMessageID = nextMessageID + "_" + index.ToString + "_" + zeitMitMs
nextMessageID = StringEx.GetShortHash(nextMessageID)
MessageIDHashSet.Add(nextMessageID)
Next
End Sub End Sub
Private Function GetSenderAddress(pMail As IMail) Private Function GetSenderAddress(pMail As IMail)
@@ -67,4 +90,16 @@ Public Class MailContainer
Return oMailBox.DomainPart Return oMailBox.DomainPart
End Function End Function
Public Sub SetMessageID(pMessageID As String)
MessageId = pMessageID
End Sub
Private Function GetEmailDate(pMail As IMail) As Date
If pMail.Date IsNot Nothing Then
Return pMail.Date
Else
Return Date.MinValue
End If
End Function
End Class End Class

View File

@@ -53,22 +53,22 @@
<HintPath>..\packages\BouncyCastle.Cryptography.2.5.0\lib\net461\BouncyCastle.Cryptography.dll</HintPath> <HintPath>..\packages\BouncyCastle.Cryptography.2.5.0\lib\net461\BouncyCastle.Cryptography.dll</HintPath>
</Reference> </Reference>
<Reference Include="DigitalData.Modules.Base"> <Reference Include="DigitalData.Modules.Base">
<HintPath>..\..\..\2_DLL Projekte\DDModules\Base\bin\Debug\DigitalData.Modules.Base.dll</HintPath> <HintPath>..\..\..\..\2_DLL Projekte\DDModules\Base\bin\Debug\DigitalData.Modules.Base.dll</HintPath>
</Reference> </Reference>
<Reference Include="DigitalData.Modules.Config"> <Reference Include="DigitalData.Modules.Config">
<HintPath>..\..\..\2_DLL Projekte\DDModules\Config\bin\Debug\DigitalData.Modules.Config.dll</HintPath> <HintPath>..\..\..\..\2_DLL Projekte\DDModules\Config\bin\Debug\DigitalData.Modules.Config.dll</HintPath>
</Reference> </Reference>
<Reference Include="DigitalData.Modules.Database"> <Reference Include="DigitalData.Modules.Database">
<HintPath>..\..\..\2_DLL Projekte\DDModules\Database\bin\Debug\DigitalData.Modules.Database.dll</HintPath> <HintPath>..\..\..\..\2_DLL Projekte\DDModules\Database\bin\Debug\DigitalData.Modules.Database.dll</HintPath>
</Reference> </Reference>
<Reference Include="DigitalData.Modules.Logging"> <Reference Include="DigitalData.Modules.Logging">
<HintPath>..\..\..\2_DLL Projekte\DDModules\Logging\bin\Debug\DigitalData.Modules.Logging.dll</HintPath> <HintPath>..\..\..\..\2_DLL Projekte\DDModules\Logging\bin\Debug\DigitalData.Modules.Logging.dll</HintPath>
</Reference> </Reference>
<Reference Include="DigitalData.Modules.Messaging"> <Reference Include="DigitalData.Modules.Messaging">
<HintPath>..\..\..\2_DLL Projekte\DDModules\Messaging\bin\Debug\DigitalData.Modules.Messaging.dll</HintPath> <HintPath>..\..\..\..\2_DLL Projekte\DDModules\Messaging\bin\Debug\DigitalData.Modules.Messaging.dll</HintPath>
</Reference> </Reference>
<Reference Include="DigitalData.Modules.Patterns"> <Reference Include="DigitalData.Modules.Patterns">
<HintPath>..\..\..\2_DLL Projekte\DDModules\Patterns\bin\Debug\DigitalData.Modules.Patterns.dll</HintPath> <HintPath>..\..\..\..\2_DLL Projekte\DDModules\Patterns\bin\Debug\DigitalData.Modules.Patterns.dll</HintPath>
</Reference> </Reference>
<Reference Include="DocumentFormat.OpenXml, Version=3.2.0.0, Culture=neutral, PublicKeyToken=8fb06cb64d019a17, processorArchitecture=MSIL"> <Reference Include="DocumentFormat.OpenXml, Version=3.2.0.0, Culture=neutral, PublicKeyToken=8fb06cb64d019a17, processorArchitecture=MSIL">
<HintPath>..\packages\DocumentFormat.OpenXml.3.2.0\lib\net46\DocumentFormat.OpenXml.dll</HintPath> <HintPath>..\packages\DocumentFormat.OpenXml.3.2.0\lib\net46\DocumentFormat.OpenXml.dll</HintPath>

View File

@@ -6,6 +6,12 @@
Public Const EMAIL_SUBJECT_REJECTED = "Beleg abgelehnt" Public Const EMAIL_SUBJECT_REJECTED = "Beleg abgelehnt"
Public Const EMAIL_WRAPPING_TEXT_DUPLICATE_MESSAGEID = "<html><body style=''font-family:""Arial"";font-size:10.0pt''>Sehr geehrte Damen und Herren,<br/><br/>
für die Email {0} konnte keine eindeutige EMail MessageID erzeugt werden.<br> Bitte prüfen sie die Logs des E-Mail Profilers.</body></html>"
Public Const EMAIL_SUBJECT_DUPLICATE_MESSAGEID = "Fehler im EMail Profiler - Es konnte keine eindeutige messageID erzeugt werden!"
Public Const EMAIL_BODY_TEXT_DUPLICATE_MESSAGEID = "<p>messageID: {0} vom {1}</p>"
Public Const DUPLICATE_MESSAGEID_CODE = "DUPLICATE MESSAGEID"
Public Const EMAIL_NO_FERDS = "<p>Ihre Email enthielt keine Dokumente.</p>" Public Const EMAIL_NO_FERDS = "<p>Ihre Email enthielt keine Dokumente.</p>"
''' <summary> ''' <summary>

View File

@@ -13,7 +13,7 @@ Imports System.Runtime.InteropServices
<Assembly: AssemblyCompany("")> <Assembly: AssemblyCompany("")>
<Assembly: AssemblyProduct("DigitalData.EMLProfiler")> <Assembly: AssemblyProduct("DigitalData.EMLProfiler")>
<Assembly: AssemblyCopyright("Copyright © 2026")> <Assembly: AssemblyCopyright("Copyright © 2026")>
<Assembly: AssemblyTrademark("3.5.3.0")> <Assembly: AssemblyTrademark("3.5.4.0")>
<Assembly: ComVisible(False)> <Assembly: ComVisible(False)>
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben: ' übernehmen, indem Sie "*" eingeben:
' <Assembly: AssemblyVersion("1.0.*")> ' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("3.5.3.0")> <Assembly: AssemblyVersion("3.5.4.0")>
<Assembly: AssemblyFileVersion("3.5.3.0")> <Assembly: AssemblyFileVersion("3.5.4.0")>

View File

@@ -106,19 +106,28 @@ Public Class clsWorkEmail
CURRENT_MAIL_FROM = m.Address CURRENT_MAIL_FROM = m.Address
Next Next
'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)
'ab hier, darf/sollte pMailMessage nicht mehr verwendet werden.
_Logger.Info($"Working on email from: [{_CurrentMail.SenderAddress}] ... Subject: [{_CurrentMail.SubjectOriginal}] ... MessageID: [{_CurrentMail.MessageId}]") 'TODO: Move all of these CURRENT_MAIL vars into a business object of type mail container
CURRENT_MAIL_BODY_ALL = "" CURRENT_MAIL_BODY_ALL = ""
CURRENT_MAIL_BODY_ANSWER1 = "" CURRENT_MAIL_BODY_ANSWER1 = ""
CURRENT_MAIL_BODY_Substr2 = "" CURRENT_MAIL_BODY_Substr2 = ""
CURRENT_MAIL_SUBJECT = "" CURRENT_MAIL_SUBJECT = ""
' Dieser Eintrag wird weiter unten wieder überschrieben. Wenn Subject IS NULL --> Exception Dim oUniqueMessageID = GetUniqueMessagID()
'CURRENT_MAIL_SUBJECT = pMailMessage.Subject.ToUpper.EscapeForSQL() If String.IsNullOrEmpty(oUniqueMessageID) = True Then
' Im Fall, dass wir keine eindeutige MessageID haben, schicken wir uns eine E-Mail
_Logger.Error($"Could not process email [{_CurrentMail.SubjectOriginal}], no unique messageID found!")
SendDuplicateWarningMail()
Return False
Else
_CurrentMail.SetMessageID(oUniqueMessageID)
_Logger.Debug($"Unique messageID found [{oUniqueMessageID}] and in use [{_CurrentMail.MessageId}]")
End If
CURRENT_MAIL_UID = poUID CURRENT_MAIL_UID = poUID
_Logger.Info($"Working on email [{poUID}] from: [{_CurrentMail.SenderAddress}] ... Subject: [{_CurrentMail.SubjectOriginal}] ... MessageID: [{_CurrentMail.MessageId}]")
If String.IsNullOrEmpty(_CurrentMail.SubjectOriginal) Then If String.IsNullOrEmpty(_CurrentMail.SubjectOriginal) Then
CURRENT_MAIL_SUBJECT = String.Empty CURRENT_MAIL_SUBJECT = String.Empty
@@ -128,24 +137,6 @@ Public Class clsWorkEmail
_Logger.Debug("Fixed Subject: [{0}]", CURRENT_MAIL_SUBJECT) _Logger.Debug("Fixed Subject: [{0}]", CURRENT_MAIL_SUBJECT)
End If End If
' Checking the messageID - could be a duplicate
_Logger.Debug($"messageID: '{_CurrentMail.MessageId}' - messageID2: '{_CurrentMail.MessageId2}'")
Dim oSql = $"Select COALESCE(MAX(GUID),0) FROM TBEMLP_HISTORY WHERE EMAIL_MSGID = '{_CurrentMail.MessageId}'"
Dim oHistoryID = _DB_MSSQL.GetScalarValue(oSql)
If oHistoryID > 0 And IS_LOCAL_TEST = False Then
_Logger.Warn("Found a MessageID already in use! Try MessageID2")
oSql = $"Select COALESCE(MAX(GUID),0) FROM TBEMLP_HISTORY WHERE EMAIL_MSGID = '{_CurrentMail.MessageId2}'"
oHistoryID = _DB_MSSQL.GetScalarValue(oSql)
If oHistoryID > 0 And IS_LOCAL_TEST = False Then
_Logger.Error("Found a MessageID2 already in use! Could not process email!")
Return False
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
@@ -269,6 +260,138 @@ Public Class clsWorkEmail
End Try End Try
End Function End Function
''' <summary>
''' Gibt die erste eindeutige messageID zurück, die generiert wurde.
'''
''' Wenn kein eindeutiger Schlüssel erzeugt werden konnte, gibt die
''' Funktion Nothing / NULL zurück
''' </summary>
''' <returns>eindeutige messageID, oder nothing im Fehlerfall</returns>
Private Function GetUniqueMessagID() As String
_Logger.Debug("GetUniqueMessagID() Start")
If IS_LOCAL_TEST = True Then
' Keine Prüfung im Test-Fall
Return _CurrentMail.MessageId
End If
Try
Dim oSql = $"SELECT COALESCE(MAX(GUID),0) FROM TBEMLP_HISTORY WHERE EMAIL_MSGID = '"
Dim oTestSQL = oSql + _CurrentMail.MessageId + "';"
Dim oHistoryID = _DB_MSSQL.GetScalarValue(oTestSQL)
If oHistoryID = 0 Then
_Logger.Info($"GetUniqueMessagID() unique messageID found from original messageID [{_CurrentMail.MessageId}]")
Return _CurrentMail.MessageId
Else
' Wenn ein Duplikat vorliegt, müssen wir weiter suchen
_Logger.Info($"GetUniqueMessagID() Activate Deep Search for unique messageID!")
_CurrentMail.InitializeHashsetOfMessageIDs()
For Each oMessageIDItem In _CurrentMail.MessageIDHashSet
oTestSQL = oSql + oMessageIDItem + "';"
oHistoryID = _DB_MSSQL.GetScalarValue(oTestSQL)
If oHistoryID = 0 Then
_Logger.Info($"GetUniqueMessagID() unique messageID found [{oMessageIDItem}]")
Return oMessageIDItem
Else
_Logger.Warn($"GetUniqueMessagID() messageID [{oMessageIDItem}] already in use")
End If
Next
End If
' Wenn wir bis hier her kommen, konnten wir keine eindeutige messageID finden
_Logger.Error($"GetUniqueMessagID() could not find unique messageID! ")
Return Nothing
Catch ex As Exception
_Logger.Error(ex)
Return Nothing
End Try
End Function
Private Function SendDuplicateWarningMail() As Boolean
Try
' Gab es die Mail schon in den letzten 6 Stunden?
Dim oCheckSQL = $"SELECT COALESCE(MAX(GUID), 0) FROM DD_ECM.dbo.TBEMLP_EMAIL_OUT WHERE REFERENCE_STRING = '{_CurrentMail.MessageId}' AND COMMENT = '{EmailStrings.DUPLICATE_MESSAGEID_CODE}' AND DATEDIFF(hour, ADDED_WHEN, getdate()) < 6;"
Dim oOutHistoryID As Integer = _DB_MSSQL.GetScalarValue(oCheckSQL)
If oOutHistoryID > 0 Then
_Logger.Warn($"Warning Mail already sent")
' EMail ging bereits raus
Return True
End If
Catch ex As Exception
_Logger.Error(ex)
Return False
End Try
Try
Dim oReference = _CurrentMail.MessageId
Dim oAdressSQL = "SELECT TOP 1 COALESCE([CAT_STRING], '') FROM [IDB].[dbo].[TBIDB_CATALOG] WHERE CAT_TITLE = 'DD_SUPPORT_EMAIL';"
Dim configString = _DB_MSSQL.GetScalarValue(oAdressSQL)
Dim oEmailTo As String = "support-flow@digitaldata.works"
If String.IsNullOrEmpty(configString) = False Then
oEmailTo = configString
End If
Dim oSubject = $"{SUBJECT_PRAFIX} - {EmailStrings.EMAIL_SUBJECT_DUPLICATE_MESSAGEID}"
Dim oCreatedWho = "DDEmailProfiler"
Dim oMaskedBodyText = String.Format(EmailStrings.EMAIL_BODY_TEXT_DUPLICATE_MESSAGEID, _CurrentMail.MessageId, _CurrentMail.EMailDate)
Dim oSubjectBodyText = String.Format(EmailStrings.EMAIL_SUBJECT_TEXT, _CurrentMail.Subject)
Dim oCompleteBodyText = oMaskedBodyText + " - " + oSubjectBodyText
Dim oFinalBodyText = String.Format(EmailStrings.EMAIL_WRAPPING_TEXT_DUPLICATE_MESSAGEID, oCompleteBodyText)
_Logger.Debug("Trying to generate Email:")
_Logger.Debug("To: {0}", oEmailTo)
_Logger.Debug("Subject: {0}", oSubject)
_Logger.Debug("Body {0}", oFinalBodyText)
Dim osql = $"Select COALESCE(MAX(GUID), 0) FROM TBEMLP_HISTORY WHERE EMAIL_MSGID = '{_CurrentMail.MessageId}'"
Dim oHistoryID As Integer = _DB_MSSQL.GetScalarValue(osql)
Dim oInsert = $"INSERT INTO [dbo].[TBEMLP_EMAIL_OUT] (
[REMINDER_TYPE_ID]
,[SENDING_PROFILE]
,[REFERENCE_ID]
,[REFERENCE_STRING]
,[WF_ID]
,[EMAIL_ADRESS]
,[EMAIL_SUBJ]
,[EMAIL_BODY]
,[COMMENT]
,[ADDED_WHO])
VALUES
(77
,{_EmailAccountID}
,{oHistoryID}
,'{_CurrentMail.MessageId}'
,77
,'{oEmailTo}'
,'{oSubject}'
,'{oFinalBodyText}'
,'{EmailStrings.DUPLICATE_MESSAGEID_CODE}'
,'{oCreatedWho}')"
Return _DB_MSSQL.ExecuteNonQuery(oInsert)
Catch ex As Exception
_Logger.Error(ex)
Return False
End Try
Return True
End Function
''' <summary> ''' <summary>
''' Wenn beim Herauslösen der Attachments festgestellt wurde, ''' Wenn beim Herauslösen der Attachments festgestellt wurde,
''' das ein Teil der _normalen_ Attachments fehlerhaft war, wird der Absender hier ''' das ein Teil der _normalen_ Attachments fehlerhaft war, wird der Absender hier

View File

@@ -221,6 +221,7 @@ Public Class clsWorker
If LocalEmlFile = "" Then If LocalEmlFile = "" Then
DeleteOrMoveEmailFile(oMailId) DeleteOrMoveEmailFile(oMailId)
End If End If
_Logger.Info("Email with Id [{0}] was successfully worked.", oMailId)
End If End If
Else Else

View File

@@ -64,19 +64,19 @@
<HintPath>..\..\..\2_DLL Projekte\DDMonorepo\GUIs.Common\bin\Debug\DigitalData.GUIs.Common.dll</HintPath> <HintPath>..\..\..\2_DLL Projekte\DDMonorepo\GUIs.Common\bin\Debug\DigitalData.GUIs.Common.dll</HintPath>
</Reference> </Reference>
<Reference Include="DigitalData.Modules.Base"> <Reference Include="DigitalData.Modules.Base">
<HintPath>..\..\..\2_DLL Projekte\DDModules\Base\bin\Debug\DigitalData.Modules.Base.dll</HintPath> <HintPath>..\..\..\..\2_DLL Projekte\DDModules\Base\bin\Debug\DigitalData.Modules.Base.dll</HintPath>
</Reference> </Reference>
<Reference Include="DigitalData.Modules.Config"> <Reference Include="DigitalData.Modules.Config">
<HintPath>..\..\..\2_DLL Projekte\DDModules\Config\bin\Debug\DigitalData.Modules.Config.dll</HintPath> <HintPath>..\..\..\..\2_DLL Projekte\DDModules\Config\bin\Debug\DigitalData.Modules.Config.dll</HintPath>
</Reference> </Reference>
<Reference Include="DigitalData.Modules.Database"> <Reference Include="DigitalData.Modules.Database">
<HintPath>..\..\..\2_DLL Projekte\DDModules\Database\bin\Debug\DigitalData.Modules.Database.dll</HintPath> <HintPath>..\..\..\..\2_DLL Projekte\DDModules\Database\bin\Debug\DigitalData.Modules.Database.dll</HintPath>
</Reference> </Reference>
<Reference Include="DigitalData.Modules.Logging"> <Reference Include="DigitalData.Modules.Logging">
<HintPath>..\..\..\2_DLL Projekte\DDModules\Logging\bin\Debug\DigitalData.Modules.Logging.dll</HintPath> <HintPath>..\..\..\..\2_DLL Projekte\DDModules\Logging\bin\Debug\DigitalData.Modules.Logging.dll</HintPath>
</Reference> </Reference>
<Reference Include="DigitalData.Modules.Messaging"> <Reference Include="DigitalData.Modules.Messaging">
<HintPath>..\..\..\2_DLL Projekte\DDModules\Messaging\bin\Debug\DigitalData.Modules.Messaging.dll</HintPath> <HintPath>..\..\..\..\2_DLL Projekte\DDModules\Messaging\bin\Debug\DigitalData.Modules.Messaging.dll</HintPath>
</Reference> </Reference>
<Reference Include="EmailProfiler.Common, Version=3.0.4.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="EmailProfiler.Common, Version=3.0.4.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>

View File

@@ -13,7 +13,7 @@ Imports System.Runtime.InteropServices
<Assembly: AssemblyCompany("Digital Data")> <Assembly: AssemblyCompany("Digital Data")>
<Assembly: AssemblyProduct("EmailProfiler Config")> <Assembly: AssemblyProduct("EmailProfiler Config")>
<Assembly: AssemblyCopyright("Copyright © 2026")> <Assembly: AssemblyCopyright("Copyright © 2026")>
<Assembly: AssemblyTrademark("3.4.0.0")> <Assembly: AssemblyTrademark("3.7.0.0")>
<Assembly: ComVisible(False)> <Assembly: ComVisible(False)>
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben: ' übernehmen, indem Sie "*" eingeben:
' <Assembly: AssemblyVersion("1.0.*")> ' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("3.4.0.0")> <Assembly: AssemblyVersion("3.7.0.0")>
<Assembly: AssemblyFileVersion("1.0.0.0")> <Assembly: AssemblyFileVersion("1.0.0.0")>

View File

@@ -770,53 +770,60 @@ Public Class frmMain
ConfigManager.Save() ConfigManager.Save()
My.Settings.Save() My.Settings.Save()
Cursor = Cursors.WaitCursor Cursor = Cursors.WaitCursor
Dim PWPlain = _Encryption.DecryptData(EMAIL_PWTextBox.Text)
'NEW
_MailSender = New Mail.MailSender(LogConfig) _MailSender = New Mail.MailSender(LogConfig)
Dim oDefault As Boolean = True Dim oDefault As Boolean = True
If CheckBoxEnableTls1_1.Checked Or CheckBoxEnableTls1_2.Checked Then If CheckBoxEnableTls1_1.Checked Or CheckBoxEnableTls1_2.Checked Then
oDefault = False oDefault = False
End If End If
Dim oOptions As New Mail.MailSession.MailSessionOptions() With { Dim oOptions As New Mail.MailSession.MailSessionOptions() With {
.EnableTls1_1 = CheckBoxEnableTls1_1.Checked, .EnableTls1_1 = CheckBoxEnableTls1_1.Checked,
.EnableTls1_2 = CheckBoxEnableTls1_2.Checked, .EnableTls1_2 = CheckBoxEnableTls1_2.Checked,
.EnableDefault = oDefault .EnableDefault = oDefault
} }
Logger.Debug($"oOptions: oOptions.EnableTls1_1: {oOptions.EnableTls1_1}, oOptions.EnableTls1_2: {oOptions.EnableTls1_2}, oOptions.EnableDefault: {oOptions.EnableDefault}") Logger.Debug($"oOptions: oOptions.EnableTls1_1: {oOptions.EnableTls1_1}, oOptions.EnableTls1_2: {oOptions.EnableTls1_2}, oOptions.EnableDefault: {oOptions.EnableDefault}")
Dim oResult As Mail.MailSession.SessionInfo = _MailSender.Connect(EMAIL_SMTPTextBox.Text, PORTTextBox.Text, EMAIL_USERTextBox.Text, PWPlain, AUTH_TYPEComboBox.Text, oOptions)
Dim oResult As Mail.MailSession.SessionInfo
' OAuth2 oder Standard-Authentifizierung
If AUTH_TYPEComboBox.Text = "OAUTH2" Then
' OAuth2-Variablen aus DB-Feldern (analog zu btntestImap)
Dim oClientId = EMAIL_SMTPTextBox.Text
Dim oClientSecret = _Encryption.DecryptData(EMAIL_PWTextBox.Text)
Dim oTenantId = ARCHIVE_FOLDERTextBox.Text
Dim oUser = EMAIL_USERTextBox.Text
oResult = _MailSender.ConnectToO365(oUser, oClientId, oTenantId, oClientSecret)
Else
' Standard-Authentifizierung (bestehend)
Dim PWPlain = _Encryption.DecryptData(EMAIL_PWTextBox.Text)
oResult = _MailSender.Connect(EMAIL_SMTPTextBox.Text, PORTTextBox.Text, EMAIL_USERTextBox.Text, PWPlain, AUTH_TYPEComboBox.Text, oOptions)
End If
If oResult.Connected = False Then If oResult.Connected = False Then
Cursor = Cursors.Default Cursor = Cursors.Default
MsgBox("Could not create a MailSession / connect to server. Please check the log.", MsgBoxStyle.Exclamation) MsgBox("Could not create a MailSession / connect to server. Please check the log.", MsgBoxStyle.Exclamation)
Exit Sub Exit Sub
End If End If
Dim oAddresses As List(Of String) = txtTestmail.Text.Split(";").ToList() Dim oAddresses As List(Of String) = txtTestmail.Text.Split(";").ToList()
Dim oAddedWhen = Now Dim oAddedWhen = Now
Dim oAttachments As New List(Of String) Dim oAttachments As New List(Of String)
Dim oBody As String = $"This is just a template body (text will be replaced within the run) - ProfileID: {EMAILIDTextBox.Text}" Dim oBody As String = $"This is just a template body (text will be replaced within the run) - ProfileID: {EMAILIDTextBox.Text}"
Dim oMessageSent = _MailSender.SendMail(oAddresses, EMAIL_FROMTextBox.Text, "Testmail from EmailProfilerConfig", oBody, oAddedWhen, oAttachments, False) Dim oMessageSent = _MailSender.SendMail(oAddresses, EMAIL_FROMTextBox.Text, "Testmail from EmailProfilerConfig", oBody, oAddedWhen, oAttachments, False)
Cursor = Cursors.Default Cursor = Cursors.Default
If oMessageSent = True Then If oMessageSent = True Then
MsgBox("Email has been send successfully.", MsgBoxStyle.Information) MsgBox("Email has been send successfully.", MsgBoxStyle.Information)
Else Else
MsgBox("Could not send the testmail. Please check the log.", MsgBoxStyle.Exclamation) MsgBox("Could not send the testmail. Please check the log.", MsgBoxStyle.Exclamation)
End If End If
'NEW END
'If _limilab.NewSMTPEmail(txtTestmail.Text, "Testmail", "This is the body (text will be replaced within profile)", EMAIL_FROMTextBox.Text, EMAIL_SMTPTextBox.Text, PORTTextBox.Text,
' EMAIL_USERTextBox.Text, PWPlain, AUTH_TYPEComboBox.Text, "frmMain-Test", "", "", True) = True Then
' MsgBox("Email has been send successfully.", MsgBoxStyle.Information)
'Else
' MsgBox("Could not send the testmail. Please check the log.", MsgBoxStyle.Exclamation)
'End If
End If End If
End Sub End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles btntestImap.Click Private Sub Button1_Click(sender As Object, e As EventArgs) Handles btntestImap.Click
ConfigManager.Save() ConfigManager.Save()
Dim oSQL = $"SELECT * FROM TBDD_EMAIL_ACCOUNT WHERE GUID = {EMAILIDTextBox.Text}" Dim oSQL = $"SELECT * FROM TBDD_EMAIL_ACCOUNT (NOLOCK) WHERE GUID = {EMAILIDTextBox.Text}"
Dim oDT As DataTable = _database.GetDatatable(oSQL) Dim oDT As DataTable = _database.GetDatatable(oSQL)
If Not IsNothing(oDT) Then If Not IsNothing(oDT) Then