Projekt-Anfragen: Tel: 07022/9319004 info@CodeDocu.de Software Entwicklung in C# WPF Asp.Net Core Vba Excel Word SQL-Server EF Linq, UWP Net
#

 

Fehlermeldung:

Failure sending mail.

Unable to read data from the transport connection

Net_io_connectionclosed

 

 

Bei SMTP Server von 1und1 smtp.1un1.de mit dem Port 465 und SSL

 

 

 

Lösung:

Der Port muss umgestellt werden auf Port 587 bei Smtp.1und1.de mit EnableSSL=true

Und beim Senden muss die DelivieryMethod auf Network gestellt werden.

            '----< Mailobject >----

            Dim email_SmtpClient As New System.Net.Mail.SmtpClient(sSMTP)

            email_SmtpClient.UseDefaultCredentials = False  '*either windows login or user-password

            email_SmtpClient.EnableSsl = cbxSSL.Checked

            email_SmtpClient.Port = tbxPort.Text

            email_SmtpClient.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network

            email_SmtpClient.Credentials = New Net.NetworkCredential(FROM_Email_Address, Password)

            email_SmtpClient.Timeout = 20000

            '--< Try: Send Mail >--

            Try

                '< send >

                email_SmtpClient.Send(email_Message)

                email_SmtpClient.Dispose()

                '</ send >

 

 

 

 

SMTP Client Code in Net 4.7 Framework Visual Basic

Public Class Form1

 

 

#Region "Buttons"

    '-------------------------< Region: Buttons >------------------

    Private Sub btnSend_Click(sender As Object, e As EventArgs) Handles btnSend.Click

 

        Dim IsSend As Boolean

        IsSend = Send_Email(tbxTo.Text, "", tbxFrom.Text, tbxPassword.Text, tbxDomain.Text, tbxSubject.Text, tbxText.Text)

        MsgBox("Email Status send is: " & IsSend)

    End Sub

    '-------------------------</ Region: Buttons >------------------

#End Region

 

 

#Region "Functions"

    '-------------------------< Region: Functions >------------------

    Public Function Send_Email(ByVal TO_Email_Address As String, ByVal CC_Email_Address As String, ByVal FROM_Email_Address As String, ByVal Password As String, ByVal sSMTP As String, ByVal Subject_Title As String, ByVal Text_Body As String, Optional ByVal Attachements_Path As String = "") As Boolean

        '-------------------------------< Send_Email() >-------------------------------

        '--< Variablen >--

        Dim Result_Send As Boolean = False

        '--</ Variablen >--

 

        '-< check >-

        If TO_Email_Address Like "" Then

            MsgBox("Email Adress TO is empty", MsgBoxStyle.Critical, "Send_Email")

            Return False

            Exit Function

        End If

        If FROM_Email_Address Like "" Then

            MsgBox("Email Adress FROM is empty", MsgBoxStyle.Critical, "Send_Email")

            Return False

            Exit Function

        End If

        '-</ check >-

 

        Dim arrEmpfaenger As Array

        arrEmpfaenger = Split(TO_Email_Address, ";", , CompareMethod.Binary)

        If arrEmpfaenger.Length > 1 Then

            TO_Email_Address = arrEmpfaenger(0)

        End If

 

 

        '----< Email >----

        Try

            '---< Mailobjekt erzeugen und senden >--

            Dim MailAdress_From As New System.Net.Mail.MailAddress(FROM_Email_Address)

            Dim MailAdress_To As New System.Net.Mail.MailAddress(TO_Email_Address)

            Dim email_Message As New System.Net.Mail.MailMessage(MailAdress_From, MailAdress_To)

 

 

            '--< add multi addresses >--

            '< TO >

            If arrEmpfaenger.Length > 1 Then

                For iAn As Integer = 1 To arrEmpfaenger.Length - 1

                    email_Message.To.Add(arrEmpfaenger(iAn))

                Next

            End If

            '</ TO >

            '< CC >

            If Not CC_Email_Address Like "" Then

                Dim arrCC As Array

                arrCC = Split(CC_Email_Address, ";", , CompareMethod.Binary)

                For iCC As Integer = 0 To arrCC.Length - 1

                    email_Message.CC.Add(arrCC(iCC))

                Next

            End If

            '</ CC >

            '--</ add multi addresses >--

 

 

            email_Message.IsBodyHtml = True

            email_Message.Subject = Subject_Title

            email_Message.Body = Text_Body

 

            '----< Mailobject >----

            Dim email_SmtpClient As New System.Net.Mail.SmtpClient(sSMTP)

            email_SmtpClient.UseDefaultCredentials = False  '*either windows login or user-password

            email_SmtpClient.EnableSsl = cbxSSL.Checked

            email_SmtpClient.Port = tbxPort.Text

            email_SmtpClient.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network

            email_SmtpClient.Credentials = New Net.NetworkCredential(FROM_Email_Address, Password)

            email_SmtpClient.Timeout = 20000

            '--< Try: Send Mail >--

            Try

                '< send >

                email_SmtpClient.Send(email_Message)

                email_SmtpClient.Dispose()

                '</ send >

 

                'Status_Text = "status=OK /send to:" & TO_Email_Address & " subject:" & Subject_Title

                Result_Send = True

            Catch ex As Exception

                '-< Fehler >-

                Dim sError As String

                If ex.InnerException Is Nothing Then

                    sError = ex.Message

                Else

                    sError = ex.Message & vbCrLf & ex.InnerException.Message

                End If

                MsgBox(sError)

                '-</ Fehler >-

            End Try

            '--</ Try: Send Mail >--

 

            '---</ Mailobjekt erzeugen und senden >--

        Catch ex As Exception

            '-< Fehler >-

            Dim sError As String

            If ex.InnerException Is Nothing Then

                sError = ex.Message

            Else

                sError = ex.Message & vbCrLf & ex.InnerException.Message

            End If

            MsgBox(sError)

            '-</ Fehler >-

        End Try

 

        '----< Mailobject >----

 

        '< Abschluss >

        Return Result_Send

        '</ Abschluss >

        '----</ Email >----

        '-------------------------------< Send_Email() >-------------------------------

    End Function

 

    '-------------------------</ Region: Functions >------------------

#End Region

 

End Class

 

 

Mobile
»
Code: Foto mit Windows verkleinern, Resize
»
C#: Bild in WinForms anzeigen
»
SMTP Fehler: Unable to read data from the transport connection
»
SMTPClient für Versenden mit SSL und Authentication
»
Winforms: Connectionstring zur Datenbank
»
Net WinForms Code: Screen zu Bitmap
»
WinForms: Code: Auflösung des Monitors wechseln per App
»
C#, WinForms: Settings speichern und lesen

.

Jobs, Projekte, Angebote für Freiberufler, Selbstständig an Info@CodeDocu.de