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