此主题相关图片如下:qq截图20210818093754.jpg
同样的项目代码,在本机(环境:win10+.NET Framework3.5)测试是OK的能正常发送邮件,但是在服务器上(环境:win server 2016 standard+.NET Framework4.6 )点击按钮就立即弹出“发送邮件失败”的错误提示?请老师帮忙看看,谢谢!
代码如下:Dim client As New System.Net.Mail.SmtpClient()
client.Host = "xxxxxx"
client.Credentials = New System.Net.NetworkCredential("fn-hn@xxxx", "Hwdxxxxxx2MDW")
client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network
Dim message As New System.Net.Mail.MailMessage
message.From = new System.Net.Mail.MailAddress("fn-hn@xxxx")
message.To.Add("yy@xxxx")
message.Subject = "李总明天来北京"
message.BodyEncoding = System.Text.Encoding.UTF8
message.IsBodyHtml = True
Dim body As String = "<html><body>内容</body></html>"
Dim content As String = "12345678<font size=7 color=red>12345678</font>"
message.Body = body.Replace("内容", content)
Try
client.Send(message)
msgbox("发送成功")
Catch ex As Exception
msgbox("发送失败:" & ex.message)
End Try