1
發送電子郵件這是我的代碼使用Gmail和VB.NET發送電子郵件:無法從VB.net
Try
Dim SmtpServer As New SmtpClient()
SmtpServer.Credentials = New Net.NetworkCredential("[email protected]", "mypassword")
SmtpServer.Port = 587
SmtpServer.Host = "smtp.gmail.com"
SmtpServer.EnableSsl = True
mail = New MailMessage()
mail.From = New MailAddress("[email protected]", "Asked for help", System.Text.Encoding.UTF8)
Mail.To.Add("[email protected]")
Mail.Subject = "A help query has been raised"
mail.Body = frm_dashboard.user_data_fetch.Item(1, 0).Value.ToString + " " + ask_for_help.txt_message_ask_help.Text
SmtpServer.Send(Mail)
MessageBox.Show("Mail sent")
Catch ex As Exception
MsgBox(ex.ToString())
MessageBox.Show("Oops something went wrong.")
End Try
但是,這表明我這個錯誤: -
在設置證書之前,試試'SmtpServer.DeliveryMethod = SmtpDeliveryMethod.Network:SmtpServer.UseDefaultCredentials = false'?改編自Gmail和.Net上的[標準答案](http://stackoverflow.com/a/32336/15639)(在C#中,但直接轉換爲VB) – MarkJ