Imports IntraSell_DLL
Imports IntraSell_Net_Base

Public Class MailSenden
    Inherits AbstractForm
    Property mail As Email

    Private Sub MyBase_Verlassen() Handles MyBase.Verlassen
        Me.Close()
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Try
            LabelErgebniss.ForeColor = Color.Black
            If Me.txtEmailEmpfänger.Text.IndexOf("@") < 0 Then
                LabelErgebniss.Text = "Prüfe Email Empfänger!"
                LabelErgebniss.ForeColor = Color.Red
                Exit Sub
            End If
            If Me.txtEmailAbsender.Text.IndexOf("@") < 0 Then
                LabelErgebniss.Text = "Prüfe Email Absender!"
                LabelErgebniss.ForeColor = Color.Red
                Exit Sub
            End If

            mail.Subject = txtBetreff.Text
            mail.EmailTo = txtEmailEmpfänger.Text
            mail.EmailFrom = txtEmailAbsender.Text
            mail.Mailtext = txtMailtext.Text

            LabelErgebniss.Text = ModuleMailGriton.DateiEinemKundenSenden(mail)
            If LabelErgebniss.Text = "Nachricht wurde geschickt!" Then
                LabelErgebniss.ForeColor = Color.Green
            Else
                LabelErgebniss.ForeColor = Color.Red
            End If
        Catch ex As Exception
            HandleAppError(ex)
        End Try
    End Sub

    Friend Sub BereiteMailVor(mail As Email)
        Me.mail = mail
        txtDatei.Text = mail.FilePath
        txtBetreff.Text = mail.Subject
        txtEmailEmpfänger.Text = mail.EmailTo
        txtEmailAbsender.Text = mail.EmailFrom
        txtMailtext.Text = mail.Mailtext
    End Sub

    Private Sub MailSenden_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.ParentBindingNavigator.Visible = False
        Me.txtEmailAbsender.Text = VarValue("Firma_Email")
    End Sub


End Class
