ASP.NET 发生伺服器错误

Home Home
引用 | 编辑 ken_3264
2007-01-26 03:19
楼主
推文 x0
复制程式
'/web' 应用程式中发生伺服器错误。
--------------------------------------------------------------------------------

指定字串不在电子邮件地址的必要表单中。 
描述: 在执行目前 Web 要求的过程中发生未处理的例外情形。请检阅堆叠追踪以取得错误的详细资讯,以及在程式码中产生的位置。 

例外详细资讯: System.FormatException: 指定字串不在电子邮件地址的必要表单中。

原始程式错误: 


行 6:          Dim eMail As New MailMessage()
行 7:          Dim MailSender As New MailAddress(TextBox1.Text)
行 8:          Dim MailReceipent As New MailAddress(TextBox2.Text)
行 9:          eMail.From = MailSender
行 10:         eMail.To.Add(MailReceipent)
 

原始程式档: C:\Inetpub\web\Default.aspx.vb    行: 8 

堆叠追踪: 


[FormatException: 指定字串不在电子邮件地址的必要表单中。]
   System.Net.Mime.MailBnfHelper.ReadMailAddress(String data, Int32& offset, String& displayName) +1343
   System.Net.Mail.MailAddress.ParseValue(String address) +246
   System.Net.Mail.MailAddress..ctor(String address, String displayName, Encoding displayNameEncoding) +78
   System.Net.Mail.MailAddress..ctor(String address) +9
   _Default.Button1_Click(Object sender, EventArgs e) in C:\Inetpub\web\Default.aspx.vb:8
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +75
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +97
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4921

为何我执行后都会出现这样的讯息,是我哪里没设定好吗??

而且我也连部上SQL我已经开启了~~伺服器却不是localhost




复制程式
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

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

<html xmlns="[url]http://www.w3.org/1999/xhtml"[/url] >
<head id="Head1" runat="server">
    <title>未命名页面</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table>
            <tr>
                <td>
                    收件帐号:</td>
                <td style="width: 138px">
                    <asp:TextBox ID="TextBox1" runat="server" Width="180px"></asp:TextBox></td>
            </tr>
            <tr>
                <td>
                    寄件帐号:</td>
                <td style="width: 138px">
                    <asp:TextBox ID="TextBox4" runat="server" Width="180px"></asp:TextBox></td>
            </tr>
            <tr>
                <td>
                    主  旨:</td>
                <td style="width: 138px">
                    <asp:TextBox ID="TextBox2" runat="server" Width="399px"></asp:TextBox></td>
            </tr>
            <tr>
                <td>
                    本  文:
                </td>
                <td style="width: 138px">
                    <asp:TextBox ID="TextBox3" runat="server" Height="127px" Width="400px"></asp:TextBox></td>
            </tr> 
            <tr>
                <td>
                    附  件:</td>
                <td style="width: 138px">
                    <asp:FileUpload ID="FileUpload1" runat="server" /></td>
            </tr>
        </table>
    
    </div>
        <asp:Button ID="Button1" runat="server" Text="Button" />
        <br />
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    </form>
</body>
</html>


献花 x0
引用 | 编辑 笑笑
2007-06-15 10:04
1楼
  
我发现你的栏位对应错了

Dim MailReceipent As New MailAddress(TextBox2.Text)
这是收件者的 email 应该是 TextBox1.Text
而寄件者的好像也有错.. 应该是 TextBox4.Text

献花 x0