首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

有关发送邮件的异常

2012-01-28 
有关发送邮件的错误程序出现错误,望高手解答程序如下:%@PageLanguage C# %%@ImportNamespace Syst

有关发送邮件的错误
程序出现错误,望高手解答


程序如下:
<%@   Page   Language= "C# "   %>
<%@   Import   Namespace= "System "   %>
<%@   Import   Namespace= "System.Net.Mail "%>

<!DOCTYPE   html   PUBLIC   "-//W3C//DTD   XHTML   1.0   Transitional//EN "   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">

<script   runat= "server ">

       
       
        protected   void   Button1_Click(object   sender,   EventArgs   e)
        {
                System.Net.Mail.MailMessage   msg   =   new   System.Net.Mail.MailMessage();
                msg.From   =   new   MailAddress(TextBox4.Text);
                msg.To.Add(new   MailAddress(TextBox1.Text));
                int   index1   =   TextBox4.Text.LastIndexOf( "@ ");
                string   str   =   TextBox4.Text.Substring(index1);
                string   str1   =   TextBox4.Text.Substring(0,   index1   +   1);
               
                msg.Subject   =   TextBox2.Text;
                msg.Body   =   TextBox3.Text;
                string   attachFile;
                attachFile=FileUpload1.FileName;
  
                System.Net.Mail.Attachment   mailadd   =   new   Attachment(FileUpload1.PostedFile.InputStream,   attachFile);


                msg.Attachments.Add(mailadd);

                SmtpClient   smt   =   new   SmtpClient();
                smt.DeliveryMethod   =   System.Net.Mail.SmtpDeliveryMethod.Network;
                string   smtpserver   =   "smtp. "   +   str;
                smt.Host   =   smtpserver;

                smt.Credentials   =   new   System.Net.NetworkCredential(str1,   TextBox5.Text.ToString());
                smt.Send(msg);
                Response.Write( "发送成功 ");
               

               
               
        }
</script>

<html   xmlns= "http://www.w3.org/1999/xhtml "   >
<head   id= "Head1 "   runat= "server ">
        <title> 无标题页 </title>
</head>
<body>
        <form   id= "form1 "   runat= "server ">


        <div>
                <asp:Label   ID= "Label5 "   runat= "server "   Text= "发件人地址: "> </asp:Label>
                <asp:TextBox   ID= "TextBox4 "   runat= "server "   Width= "184px "> </asp:TextBox> <br   />
                <br   />
                <asp:Label   ID= "Label6 "   runat= "server "   Text= "密码: "> </asp:Label>
                <asp:TextBox   ID= "TextBox5 "   runat= "server "   TextMode= "Password "> </asp:TextBox> <br   />
                <br   />
                &nbsp; <asp:Label   ID= "Label1 "   runat= "server "   Text= "收件人地址: "> </asp:Label>
                <asp:TextBox   ID= "TextBox1 "   runat= "server "   Width= "216px "> </asp:TextBox> <br   />
                <br   />
                <asp:Label   ID= "Label2 "   runat= "server "   Text= "主题: "> </asp:Label>
                <asp:TextBox   ID= "TextBox2 "   runat= "server "   Width= "219px "> </asp:TextBox> <br   />
                <br   />
                <asp:Label   ID= "Label4 "   runat= "server "   Text= "附件: "> </asp:Label>
                &nbsp;
                <asp:FileUpload   ID= "FileUpload1 "   runat= "server "   /> <br   />
                <br   />
                <asp:Label   ID= "Label3 "   runat= "server "   Text= "内容: "> </asp:Label> <br   />
                <asp:TextBox   ID= "TextBox3 "   runat= "server "   Height= "176px "   Width= "348px "> </asp:TextBox> <br   />
                <br   />
                <br   />
                <asp:Button   ID= "Button1 "   runat= "server "   Text= "发送 "   OnClick= "Button1_Click "   />
                <asp:Button   ID= "Button2 "   runat= "server "   Text= "取消 "   /> </div>
        </form>
</body>
</html>

------解决方案--------------------


把错误信息贴出来啊
[解决办法]
对比一下这个

http://www.51aspx.com/CV/JH1GEZ9ACZA70
[解决办法]
我估计你是用了新注册的邮箱去做发送把,,,我尝试过新注册的163 126 的邮箱都发不出,,旧注册的还可以发,没问题!

热点排行