Form logging und methode wie im Service benutzen
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
Imports System.ComponentModel
|
||||
Imports System.IO
|
||||
Imports System.Net.Mail
|
||||
Imports System.Text.RegularExpressions
|
||||
Imports System.Windows.Forms.VisualStyles.VisualStyleElement.Tab
|
||||
Imports DevExpress.XtraPrinting.Export
|
||||
Imports DigitalData.GUIs.Common
|
||||
Imports DigitalData.Modules.Config
|
||||
Imports DigitalData.Modules.Database
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.Messaging
|
||||
Imports DigitalData.Modules.Config
|
||||
Imports DigitalData.Modules.Messaging.Mail
|
||||
Imports DigitalData.GUIs.Common
|
||||
Imports EmailProfiler.Common
|
||||
|
||||
Public Class frmMain
|
||||
@@ -24,6 +27,8 @@ Public Class frmMain
|
||||
Private _DBConfig As ClassDBConfig.Config
|
||||
Private MyConnectionString As String
|
||||
|
||||
Private _MailSender As Mail.MailSender
|
||||
|
||||
Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles Me.Load
|
||||
Try
|
||||
LogConfig = New LogConfig(LogConfig.PathType.CustomPath, Path.Combine(My.Application.Info.DirectoryPath, "Log"), Nothing, My.Application.Info.CompanyName, My.Application.Info.ProductName)
|
||||
@@ -728,16 +733,44 @@ Public Class frmMain
|
||||
Private Sub btnsendtestmail_Click(sender As Object, e As EventArgs) Handles btnsendtestmail.Click
|
||||
If txtTestmail.Text <> String.Empty Then
|
||||
ConfigManager.Save()
|
||||
My.Settings.Save()
|
||||
Cursor = Cursors.WaitCursor
|
||||
Dim PWPlain = _Encryption.DecryptData(EMAIL_PWTextBox.Text)
|
||||
'NEW
|
||||
_MailSender = New Mail.MailSender(LogConfig)
|
||||
Dim oOptions As New Mail.MailSession.MailSessionOptions() With {
|
||||
.EnableTls1_1 = False,
|
||||
.EnableTls1_2 = False,
|
||||
.EnableDefault = True
|
||||
}
|
||||
Dim oResult As Mail.MailSession.SessionInfo = _MailSender.Connect(EMAIL_SMTPTextBox.Text, PORTTextBox.Text, EMAIL_USERTextBox.Text, PWPlain, AUTH_TYPEComboBox.Text, oOptions)
|
||||
|
||||
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
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user