给定程序无法正常工作 [英] Not working given program

查看:67
本文介绍了给定程序无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么此代码未运行

Why this code is not running

<%@ Page Language="C#" EnableSessionState="False" EnableViewState="False" Trace="False" Debug="True"%>

<%@ Import Namespace="System.Configuration" %>
<%@ Import Namespace="System.Web" %>
<%@ Import Namespace="System.Web.Security" %>
<%@ Import Namespace="System.Web.UI" %>
<%@ Import Namespace="System.Web.UI.WebControls" %>
<%@ Import Namespace="System.Web.UI.HtmlControls" %>
<%@ Import Namespace="System.Net.Mail" %>

<script  runat="server">
 void send(Object sender, EventArgs e)
    {
   SmtpClient smtpClient = new SmtpClient();
   MailMessage message = new MailMessage(); 
   try       
   {        
    MailAddress fromAddress = new MailAddress(t1.Text, t2.Text);
    smtpClient.Host = "webmail.kamnatrust.com";     
    smtpClient.Port = 80; 
    message.From = fromAddress;
    message.To.Add("janardan.ind@gmail.com");
    message.Subject = "Feedback";
    message.IsBodyHtml = false;
    message.Body = t3.Text;
    smtpClient.Send(message);
    l1.Text = "Email successfully sent.";
    }
    catch (Exception ex)
    {
    l1.Text = "Send Email Failed.<br>" + ex.Message;
    }
    }
	}
</script>
<html>

<body>
<form  runat="server">
<table>
<tr><td>
 Enter Email<asp:TextBox ID="t1" runat="server"/><br>
 Name <asp:TextBox ID="t2" runat="server"/>
  <br>
  Subject<asp:TextBox ID="t3" runat="server"/>
  <br>
 Click to send <asp:Button ID="b1" Text="send" OnClick="send" runat="server"/>
 <br>
 <asp:Label ID="l1" runat="server"/>
</br></br></br></br></td></tr>
</table>
</form>
</body>
</html>
</br>

推荐答案

您所有其他版本均无法正常运行的原因相同.您确实需要花更多时间研究此类 [ ^ ]及其关联对象.然后,您需要学习如何访问所选主机的smtp端口.如有必要,请查看主机系统的帮助,以找到要使用的正确主机名和端口号.最后,请确保您选择的主机实际上是提供 SMTP服务.
The same reason that all your other versions are not working. You really need to spend some more time studying this class[^] and its associated objects. You then need to learn how to access the smtp port of your chosen host. If necessary look at the host system''s help to find out the correct host name and port number to use. And finally, make sure you have chosen a host that actually provides an SMTP service.


您的邮件服务器的SMTP地址绝对不在端口80上.

与您联系邮件服务器管理员,并询问SMTP端口号(默认为25,但可以是其他名称).
Your mail server''s SMTP address is definitely not on port 80.

Contact you mail servers admin and ask for the SMTP port number (default is 25 but it could be something else).


这篇关于给定程序无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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