电子邮件发件人显示“已拒绝中继”错误

时间:2016-11-08 23:31:50

标签: vb.net email smtp

我在我的电子邮件发件人中使用此代码但收到错误。 首先我尝试使用gmail,它正确地发送,但是当我尝试使用smtp2go时,我得到一个“未经认证的发件人拒绝接收”错误。

我还想添加“发件人电子邮件”选项和“发件人姓名”和“收件人姓名”。 谁能帮我? 我正在使用Visual Basic 10。

这是电子邮件发件人代码

Imports System.Net
Imports System.Net.Mail
Public Class Form1
    Private Sub FlatButton1_Click(sender As Object, e As EventArgs) Handles FlatButton1.Click
        Try
            Dim client As New SmtpClient
            Dim message As New MailMessage
            client.UseDefaultCredentials = False
            client.Credentials = New NetworkCredential(Me.TextBox1.Text, Me.TextBox2.Text)
            client.Port = "2525"
            client.EnableSsl = True
            client.Host = "mail.smtp2go.com"
            message = New MailMessage
            message.From = New MailAddress(Me.TextBox3.Text)
            message.To.Add(Me.TextBox4.Text)
            message.Subject = Me.TextBox5.Text
            message.IsBodyHtml = True
            message.Body = Me.TextBox6.Text
            client.Send(message)
            MsgBox("Mail Sent", MsgBoxStyle.ApplicationModal, Nothing)
        Catch ex As Exception
            MsgBox(ex.ToString, MsgBoxStyle.ApplicationModal, Nothing)
        End Try
    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
        Me.FlatComboBox1.Text = "mail.smtp2go.com"
    End Sub

    Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged
    End Sub

    Private Sub FlatComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FlatComboBox1.SelectedIndexChanged
    End Sub
End Class

0 个答案:

没有答案