我一直在阅读 Stack Overflow 上的一些帖子,这些帖子看起来与我的相似,并且我已经调整了我的代码,但它仍然无法正常工作。我的代码在下面供您阅读:
Dim ss As SmtpClient = New SmtpClient("smtp.gmail.com", 587)
'Dim ss As SmtpClient = New SmtpClient("smtp.gmail.com",465 )
'Dim ss As SmtpClient = New SmtpClient("smtp.gmail.com", 25)
ss.Timeout = 10000
ss.DeliveryMethod = SmtpDeliveryMethod.Network
ss.UseDefaultCredentials = False
ss.EnableSsl = True
ss.UseDefaultCredentials = False
ss.Credentials = New NetworkCredential("name@gmail.com", "name@123")
Dim subject As String = "Approval request for Quotation with Order Number: " + Me.OrderNo
Dim body As String = "Dear Sir/Madam," + vbCrLf + " This is to bring to your notice the quotation for the Client " + Me.cmbCustomer.SelectedItem.Text + " and Order Number " + Me.OrderNo & _
" which is awaiting your approval." + vbCrLf + "Click here to view and approve the Quotation: http:192.168.20.7/appname/Sales/ManageInvoices.aspx" + vbCrLf & _
" Kindly revert after approval. Thank you." + vbCrLf + "Regards."
Dim To1, To2, To3 As String
Dim mm As MailMessage = New MailMessage()
mm.From = New MailAddress("name@gmail.com")
To1 = "usernameTo1@domain.com"
To2 = "usernameTo2@domain.com"
To3 = "usernameTo3@gmail.com"
'To is a collection of MailAddress types
mm.To.Add(To1)
mm.To.Add(To2)
mm.To.Add(To3)
mm.Subject = subject
mm.Body = body
mm.BodyEncoding = UTF8Encoding.UTF8
'mm.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure
Try
ss.Send(mm)
Catch ex As SmtpException
Me.lblerr.Text = "SMTP Err:" & ex.ToString
End Try
那么是什么导致邮件无法到达目的地呢?我根本没有收到任何错误消息。请帮忙谢谢。