1

这是我使用 GMAIL 和 VB.NET 发送电子邮件的代码:

        Try
            Dim SmtpServer As New SmtpClient()
            SmtpServer.Credentials = New Net.NetworkCredential("mygmailid@gmail.com", "mypassword")
            SmtpServer.Port = 587
            SmtpServer.Host = "smtp.gmail.com"
            SmtpServer.EnableSsl = True

            mail = New MailMessage()
            mail.From = New MailAddress("mygmailid@gmail.com", "Asked for help", System.Text.Encoding.UTF8)
            Mail.To.Add("sendtoemail@id")
            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

但这向我显示了这个错误:-

在此处输入图像描述

4

1 回答 1

1

这是我的顺序,你可能想试试这个:

Dim SMTP As New SmtpClient("smtp.gmail.com")
SMTP.Credentials = New System.Net.NetworkCredential("gmailID", "password")
SMTP.EnableSsl = True
SMTP.Port = "587"
SMTP.Send(Mail)

另请注意,在传递我的凭据时,我实际上并没有使用“@gmail.com”。

于 2013-08-15T14:09:12.793 回答