c# - Sending email through asp.net -


this design page :

<%@ page language="c#" autoeventwireup="true" codefile="register.aspx.cs" inherits="register" %>  <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">  <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server">     <title></title> </head> <body>     <form id="form1" runat="server">     <div>     <table style="border:1px solid" align="center">     <tr><td>username:</td><td><asp:textbox runat="server" id="txtusername"></td></tr>     <tr><td>password:</td><td><asp:textbox runat="server" id="txtpassword" textmode="password"></td></tr>     <tr><td valign="top">address:</td><td><asp:textbox runat="server" id="txtadress" textmode="multiline"></td></tr>     <tr><td>email-id:</td><td><asp:textbox runat="server" id="txtemail"></td></tr>     <tr><td colspan="2" align="center"><asp:button runat="server" id="btnregister"              text="register" onclick="btnregister_click" /></td></tr>     </table>      </div>     </form> </body> </html> 

this code page:

using system; using system.collections.generic; using system.linq; using system.web; using system.web.ui; using system.web.ui.webcontrols; using system.net.mail;  public partial class register : system.web.ui.page {     protected void page_load(object sender, eventargs e)     {      }     protected void btnregister_click(object sender, eventargs e)     {         mailmessage msg = new mailmessage();         msg.to.add(txtemail.text);         msg.from = new mailaddress("mysiteadmin@peers");         msg.subject="thanks registraion";         msg.body="thanks registraion";         smtpclient obj = new smtpclient();         obj.host = "sri";obj.send(msg);         response.write("<h2>registered</h2>");      } 

}

here getting error below.... can please 

service not available, closing transmission channel. server response was: cannot connect smtp server 100.64.243.189 (100.64.243.189:25), connect error 10061 description: unhandled exception occurred during execution of current web request. please review stack trace more information error , originated in code. exception details: system.net.mail.smtpexception: service not available, closing transmission channel. server response was: cannot connect smtp server 100.64.243.189 (100.64.243.189:25), connect error 10061

source error:  line 21:         msg.body="thanks registraion"; line 22:         smtpclient obj = new smtpclient(); line 23:         obj.host = "sri";obj.send(msg); line 24:         response.write("<h2>registered</h2>"); line 25: 

there may 2 cause:

  1. this results trying connect service inactive on foreign host.

  2. sometimes 10061 error caused either firewall or anti-virus software presence on local computer or network connection.

either 1 may blocking ports needed make successful connection server. either went wrong host, or server application you're trying contact not executing. check destination address using. check, if used hostname, did resolve correct address or not..


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

css - Can I use the :after pseudo-element on an input field? -