在asp.net中发送电子邮件连接尝试失败,因为连接方在一段时间后没有正确响应 [英] sending email in asp.net A connection attempt failed because the connected party did not properly respond after a period of time

查看:75
本文介绍了在asp.net中发送电子邮件连接尝试失败,因为连接方在一段时间后没有正确响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


大家好,


 


我发送电子邮件,但在此行收到此错误


smtpClient.Send(mail);



"连接尝试失败,因为连接方在一段时间后没有正确响应,或者建立的连接失败,因为连接的主机未能响应IP地址...



 


MailMessage mail =
new
MailMessage ();


mail.To.Add(




" test@mywebname.com" );


mail.From =




new
MailAddress (txtEmail.Text);


mail.Subject =




< span style ="color:#a31515; font-size:x-small"> "测试电子邮件" ;


 




string Body =
"Demo Email trial" ;


mail.Body =正文;



mail.IsBodyHtml =




true ;


 




SmtpClient smtpClient =
new
SmtpClient ();


smtpClient.Host =




" mail.mywebname.com" ;


smtpClient.Credentials =




new System.Net。 NetworkCredential " test@mywebname.com"
" passwd" );


smtpClient.Send(mail );


 


plz帮助我



解决方案

检查您的主机地址是否正确。我认为代码中缺少SMTP客户端的端口。检查你的Smtp客户端是否需要安全连接(SSL)。问题可能是因为上述三个中的一个。


下面的链接包含使用Smtpclient发送电子邮件的示例代码


http://gauravkhanna.blog.co.in/2008/07/13/send-email-from-your-gmail-account/


Hi everyone,

 

I am sending email , but getting this error on this line

smtpClient.Send(mail);

"A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond IP adress ...

 

MailMessage mail = new MailMessage();

mail.To.Add(

"test@mywebname.com");

mail.From =

new MailAddress(txtEmail.Text);

mail.Subject =

"Testing Email";

 

string Body = "Demo Email trial";

mail.Body = Body;

mail.IsBodyHtml =

true;

 

SmtpClient smtpClient = new SmtpClient();

smtpClient.Host =

"mail.mywebname.com";

smtpClient.Credentials =

new System.Net.NetworkCredential("test@mywebname.com", "passwd");

smtpClient.Send(mail);

 

plz help me

解决方案

Check whether your host address is correct or not.  I think  Port for your SMTP Client is missing in the code. Also do check whether your Smtp Client require Secure Connection (SSL) or not. The problem could be because one of above three.

Below link contains example code to send email using Smtpclient

http://gauravkhanna.blog.co.in/2008/07/13/send-email-from-your-gmail-account/


这篇关于在asp.net中发送电子邮件连接尝试失败,因为连接方在一段时间后没有正确响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆