无法通过VB.net发送电子邮件

时间:2014-11-14 02:45:48

标签: vb.net email smtp smtpclient

我已经构建了一个可以直接向特定电子邮件发送电子邮件的vb应用程序。 我已经按照我在互联网上找到的每条指令,但它总是给我同样的错误。 这是错误的样子

the smtp server requires a secure connection or the client was not authenticated 5.5.1.....

这是我发送电子邮件的代码:

Try
            Dim Smtp_Server As New SmtpClient
            Dim e_mail As New MailMessage()
            Smtp_Server.DeliveryMethod = SmtpDeliveryMethod.Network
            Smtp_Server.UseDefaultCredentials = False
            Smtp_Server.Credentials = New Net.NetworkCredential("myemail@gmail.com", "mypassword")
            Smtp_Server.Port = 587
            Smtp_Server.EnableSsl = True
            Smtp_Server.Host = "smtp.gmail.com"

            'e_mail = New MailMessage()
            e_mail.From = New MailAddress("myemail@gmail.com")
            e_mail.To.Add("anotheremail@gmail.com")

            e_mail.Subject = "Testing Email"
            e_mail.IsBodyHtml = False
            e_mail.Body = "Ngetest email scheduler"
            Smtp_Server.Send(e_mail)

            MsgBox("Mail Sent")

        Catch error_t As Exception
            MsgBox(error_t.ToString)
        End Try

任何人都可以帮我解决一下这个问题吗?

0 个答案:

没有答案