本文介绍了如何解决发送电子邮件错误:远程名称无法解析?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在尝试通过电子邮件重设密码的方法
但是,当我单击按钮时,它会提示
i have trying to on how to do on reseting password by email
however when i click on the button it prompt
"The remote name could not be resolved: 'myemail@hotmail.com' at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout) at System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback) at System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback) at System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) at System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint) at System.Net.Mail.SmtpTransport.GetConnection(ServicePoint servicePoint) at System.Net.Mail.SmtpClient.GetConnection() at System.Net.Mail.SmtpClient.Send(MailMessage message)"
在lblMessage标签中,那么我该如何解决呢?
in the lblMessage label so how should i solve this ?
'create your variables
Dim strSubject As String = "Your Password Has Been Reset"
Dim strFromEmail As String = txtEmail.Text
Dim strFromName As String = "My Website Administrator"
Dim strNewPassword As String = GeneratePassword().ToString() 'This is where you'd call the new password string.
Try
'create the new mail message[/color]
Dim MailMsg As MailMessage = New MailMessage()
'cretate the FROM[/color]
MailMsg.From = New MailAddress(strFromEmail)
'create the subject[/color]
MailMsg.Subject = strSubject
'We obviously need to create the TO - otherwise it goes nowhere.
' Dim 'assuming there was a form to fill out and they put the right email address in. As
MailMsg.To.Add(txtEmail.Text)
MailMsg.IsBodyHtml = True 'I decided to make it html - so I could format the text.
MailMsg.Body = "<h1>The following email was sent to you by " + strFromName + ".</h1><br />"
MailMsg.Body += "<p>Apparently, you needed your password reset - So here it is: <br />"
MailMsg.Body += "New Password " + strNewPassword + "<br />"
'MailMsg.Body += "If you didn't request this, then - oops, you might wanna think about changing it, now. ""
'MailMsg.Body += "<p>Click the following link to change your password:</p>"
'MailMsg.Body += "<p>http://www.mywebsite.com/passwordChangeThing/Default.aspx</P>"
'utilizing SMTP (simple mail transfer protocol)
Dim smtp As SmtpClient = New SmtpClient()
smtp.Host = "myemail@hotmail.com" 'if my domain had a way of sending out emails.
'Dim 'send it As
smtp.Send(MailMsg)
lblMessage.Text = "Message Sent Successfully" 'tell the person that the email was sent.
Catch ex As Exception
lblMessage.Text = "Error: " + ex.ToString() 'or tell the person that they screwed up and it's all their fault.... or what the actual error was.
End Try
推荐答案
smtp.Host = "smtp.live.com" // whatever the mail server for the hotmail
这篇关于如何解决发送电子邮件错误:远程名称无法解析?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!