0
我一直在经历堆栈溢出看起来类似于我的一些帖子,我已经调整了我的代码,但它仍然无法正常工作。我的代码准备好参加以下考试:邮件没有被发送使用smtp客户端和ASP.NET
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("[email protected]", "[email protected]")
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("[email protected]")
To1 = "[email protected]"
To2 = "[email protected]"
To3 = "[email protected]"
'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
那么,如何让邮件不能到达目的地呢?我没有收到任何错误消息。请帮忙谢谢。
其中他在第一行完成:'新SmtpClient(“smtp.gmail.com”,587)' - 第二个参数是端口号。 –
我试着再次运行,现在出现错误:'无法解析远程名称:'smtp.gmail.com''运行第二次并关闭防火墙后,出现另一个错误:'连接尝试失败因为连接方在一段时间后没有正确响应,或者由于连接的主机未能响应而建立连接失败173.194.67.109:587' – Charles
非常通用的错误消息。可能是代理问题,防火墙问题等。 – IrishChieftain