我正在尝试让表单向自己发送电子邮件,但由于某种原因它不起作用,我不知道为什么。当我提交表单时,它会显示以下堆栈跟踪:在 System.Net.Mail.SmtpClient.Send(MailMessage message) 在 emailform.index.send_Click(Object sender, EventArgs e) 在 C:\Users\PC\Desktop\Projects\emailform\emailform\index.aspx.cs:line 28有人有想法么?我刚开始学习C# 和 ASP.NET,所以它可能是显而易见的。这是代码:<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="index.aspx.cs" Inherits="emailform.index" %><!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title></title></head><body> <form id="form1" runat="server"> <br /> <br /> <table align="center" width="60%"> <tr> <td>to:</td> <td><asp:TextBox ID="to" runat="server" Text="email@gmail.com" width="60%" ></asp:TextBox></td> </tr> <tr> <td>from:</td> <td><asp:TextBox ID="from" runat="server" Text="myemail@outlook.com" Width="60%"></asp:TextBox></td> </tr> <tr> <td>subject</td> <td><asp:TextBox ID="subject" runat="server" Text="TEST" Width="60%"></asp:TextBox></td> </tr> <tr> <td>body</td> <td><asp:TextBox ID="body" runat="server" Text="this is a test message" Height="30%" Width="60%" TextMode="MultiLine"></asp:TextBox></td> </tr> <tr> <td></td> <td><asp:Button ID="send" onClick="send_Click" runat="server" Text="send" /></td> </tr> <tr> <td></td> <td><asp:Label ID="status" runat="server"></asp:Label></td> </tr> </table> </form></body></html>这是C#: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;namespace emailform{ public partial class index : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { }
- 3 回答
- 0 关注
- 251 浏览
添加回答
举报
0/150
提交
取消