任何人都可以看到为什么这不会发送...我多次检查电子邮件地址和密码...
Imports System.Net.Mail
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim Mail As New MailMessage
Mail.From = New MailAddress("myemail@googlemail.com")
Mail.To.Add("myemail@googlemail.comm")
Mail.Subject = "test"
Mail.Body = txtcomment.Text
Dim smtp As New SmtpClient("smtp.gmail.com")
smtp.Port = 587
smtp.EnableSsl = True
smtp.Credentials = New System.Net.NetworkCredential("myemail@googlemail.com", "mypassowrd")
smtp.Send(Mail)
lblconfirm.Text = "Sent Successfully"
Catch ex As Exception
lblconfirm.Text = "There was an error"
End Try
End Sub
答案 0 :(得分:0)
一些想法:
答案 1 :(得分:0)
你真的收到任何错误吗?错误消息非常有用。
如果您没有收到任何错误消息,请考虑以下几点。
希望其中一些有用。
答案 2 :(得分:0)
我们需要收到错误消息才能知道问题所在。但是,请在添加此行后进行检查:
smtp.UseDefaultCredentials = false;