O Auth aus Oberfäche
This commit is contained in:
@@ -770,53 +770,60 @@ Public Class frmMain
|
||||
ConfigManager.Save()
|
||||
My.Settings.Save()
|
||||
Cursor = Cursors.WaitCursor
|
||||
Dim PWPlain = _Encryption.DecryptData(EMAIL_PWTextBox.Text)
|
||||
'NEW
|
||||
|
||||
_MailSender = New Mail.MailSender(LogConfig)
|
||||
Dim oDefault As Boolean = True
|
||||
If CheckBoxEnableTls1_1.Checked Or CheckBoxEnableTls1_2.Checked Then
|
||||
oDefault = False
|
||||
End If
|
||||
Dim oOptions As New Mail.MailSession.MailSessionOptions() With {
|
||||
.EnableTls1_1 = CheckBoxEnableTls1_1.Checked,
|
||||
.EnableTls1_2 = CheckBoxEnableTls1_2.Checked,
|
||||
.EnableDefault = oDefault
|
||||
}
|
||||
.EnableTls1_1 = CheckBoxEnableTls1_1.Checked,
|
||||
.EnableTls1_2 = CheckBoxEnableTls1_2.Checked,
|
||||
.EnableDefault = oDefault
|
||||
}
|
||||
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
|
||||
Cursor = Cursors.Default
|
||||
MsgBox("Could not create a MailSession / connect to server. Please check the log.", MsgBoxStyle.Exclamation)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Dim oAddresses As List(Of String) = txtTestmail.Text.Split(";").ToList()
|
||||
Dim oAddedWhen = Now
|
||||
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 oMessageSent = _MailSender.SendMail(oAddresses, EMAIL_FROMTextBox.Text, "Testmail from EmailProfilerConfig", oBody, oAddedWhen, oAttachments, False)
|
||||
Cursor = Cursors.Default
|
||||
|
||||
If oMessageSent = 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
|
||||
'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 Sub
|
||||
|
||||
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles btntestImap.Click
|
||||
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)
|
||||
If Not IsNothing(oDT) Then
|
||||
|
||||
|
||||
Reference in New Issue
Block a user