我几乎尝试了所有事情,但无法让它发挥作用。我将不胜感激。谢谢
Imports Microsoft.VisualBasic, System.Net.Mail
Shared Sub SendMailHTML(ByVal ToAdd, ByVal FromAdd, ByVal Message, ByVal Subject)
Dim mail As New MailMessage()
Dim SmtpServer As New SmtpClient()
SmtpServer.Host = "smtp.gmail.com"
SmtpServer.Credentials = New Net.NetworkCredential("xxxx@gmail.com", "xxxxxx")
SmtpServer.UseDefaultCredentials = False
SmtpServer.Port = 465
SmtpServer.EnableSsl = True
SmtpServer.Timeout = 5000
SmtpServer.DeliveryMethod = SmtpDeliveryMethod.Network
Try
mail.From = New MailAddress("xxxxx@gmail.com")
mail.To.Add("xxxxxx@gmail.com")
SmtpServer.Send(Mail)
Catch ex As Exception
MsgBox(ex.ToString())
End Try
End Sub