我试图在点击按钮后发送电子邮件。但这是我得到的例外
我的代码有问题吗?我已经尝试进入我的Gmail设置并打开“访问不太安全的应用程序”,仍然存在问题。
.tooltip.top .tooltip-arrow:after {
content: " ";
position: absolute;
width: 0;
height: 0;
border-color: transparent;
border-style: solid;
left: -17px;
top: -5px;
border-width: 12px;
border-top-color: #003f6e;
border-bottom:none;
}
.tooltip.top .tooltip-arrow:before {
content: " ";
position: absolute;
width: 0;
height: 0;
border-color: transparent;
border-style: solid;
left: -15px;
top: -5px;
border-width: 10px 10px 0;
border-top-color: #fff;
border-bottom:none;
z-index: 1;
}
行Imports System.Net.Mail
Imports System.Net
Partial Class _Default
Inherits System.Web.UI.Page`
Protected Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
Try
Dim mailMessage As New MailMessage("group2@gmail.com", "ndumisosizwe@gmail.com")
mailMessage.Subject = "Mail Body"
mailMessage.Body = "This is a test email"
Dim SmtpClient As New SmtpClient("smtp.gmail.com", 587)
Dim credentials As New NetworkCredential("group2@gmail.com", "myPasswordHere")
SmtpClient.Credentials = credentials
SmtpClient.EnableSsl = True
SmtpClient.Send(mailMessage)
MsgBox("Email sent successfully")
Catch ex As Exception
MsgBox("Email Failed ! " & ex.ToString)
End Try
End Sub
End Class