我的代码已经成功发送了三年的电子邮件。截至一周前,这些电子邮件未能到达。我想知道AVG是导致问题还是McFee WebProtector。
我提供了以下代码,以便您可以看到我的方法。
的web.config
<appSettings>
<add key="FromAddress" value="webmaster@mydomain.com" />
<add key="FromName" value="My Domain Website" />
<add key="ToAddress" value="webmaster@mydomain.com" />
<add key="ToName" value="Web Master" />
<add key="SendMailOnError" value="false" />
</appSettings>
<mailSettings>
<smtp deliveryMethod="Network" from="Web Master <me@btinternet.com>">
<network host="mail.btinternet.com" userName="me@btinternet.com" password="NinaDobreva" />
</smtp>
</mailSettings>
网络
Dim fileName As String = Server.MapPath("~/App_Data/ContactForm.txt")
Dim mailBody As String = File.ReadAllText(fileName)
mailBody = mailBody.Replace("##Name##", Name.Text)
mailBody = mailBody.Replace("##Email##", EmailAddress.Text)
mailBody = mailBody.Replace("##HomePhone##", PhoneHome.Text)
mailBody = mailBody.Replace("##BusinessPhone##", PhoneBusiness.Text)
mailBody = mailBody.Replace("##Comments##", Comments.Text)
Dim myMessage As MailMessage = New MailMessage()
myMessage.Subject = "Response from Website Contact Form"
myMessage.Body = mailBody
myMessage.From = New MailAddress(ConfigurationManager.AppSettings.Item("FromAddress").ToString, ConfigurationManager.AppSettings.Item("FromName").ToString)
myMessage.To.Add(New MailAddress(ConfigurationManager.AppSettings.Item("ToAddress").ToString, ConfigurationManager.AppSettings.Item("ToName").ToString))
Dim mySmtpClient As SmtpClient = New SmtpClient()
Try
mySmtpClient.Send(myMessage)
Message.Text = "Thank you. Your message has been sent."
Catch
lblResult.Text = "Transmission error, please try again."
lblResult.ForeColor = Drawing.Color.Red
Message.Text = "Error sending message. Message not sent."
End Try
Else
lblResult.Text = "Incorrect, please try again."
lblResult.ForeColor = Drawing.Color.Red
Message.Text = "Message not sent."
End If
在调试中运行它会执行mySmtpClient.Send语句。无论如何我可以跟踪之后发生的事情吗?
我已经手动(通过outlook)将电子邮件发送到相同的电子邮件地址,以检查它们是否仍在工作,它们是什么。我还检查了所有垃圾文件夹等。
但是,由于所有这一切都在起作用(自上周二以来),这让我觉得它必定是一些非代码问题?任何想法都会非常感激。
答案 0 :(得分:0)
Karen Payne的建议导致问题消失,这是一个很好的做法。见下文。
我强烈建议订阅SendCompleted,使用下面的示例查看是否存在错误。 systemnetmail.com/faq/4.6.aspx - 凯伦佩恩昨天