http://community.csdn.net/Expert/topic/3284/3284408.xml?temp=.7161524
解决方案 »
- 服务器上Microsoft.Jet.OLEDB 可以打开 xls文件,可是打不开csv文件
- 初学者,麻烦给一个判断textBox1输入的的值是否为整数的例子
- 请问SoapHeader在Server端怎样被初始化?
- 如何做每个网站的高级查询?
- C# 取消事务的问题
- PHP函数如何用C#实现?
- 求救一个算法!
- 怎么用安装程序注册DLL到全局程序集?在线等
- 怎么将excel中的数据导入到sql2000中
- 请教CLS-compliant问题。
- 孟子E章,请进! 请教您http://dotnet.aspx.cc/首页(asp.net /c# /vb.net/webservice等)布局及调用数据库显示问题!
- 关于EXCEL的导入问题。。。请那位高手帮个帮了
http://support.microsoft.com/default.aspx?scid=kb;zh-cn;313114
<HTML>
<HEAD>
<title></title>
</HEAD>
<body>
<b>演示发送邮件</b>
<form runat="server">
<table border="1">
<tr>
<td colspan="2"><b>最简单的邮件发送</b></td>
</tr>
<tr>
<td colspan="2"><asp:Label id="lblShowMsg" ForeColor="red" runat="server" /></td>
</tr>
<tr>
<td>收件人:</td>
<td><asp:TextBox id="tbTo" runat="server" /></td>
</tr>
<tr>
<td>发件人:</td>
<td><asp:TextBox id="tbFrom" runat="server" /></td>
</tr>
<tr>
<td>邮件主题:</td>
<td><asp:TextBox id="tbSubject" runat="server" /></td>
</tr>
<tr>
<td colspan="2">邮件内容:</td>
</tr>
<tr>
<td colspan="2"><asp:TextBox TextMode="MultiLine" Rows="10" Columns="50" id="tbMsgText" runat="server" /></td>
</tr>
<tr>
<td><asp:Button id="btnSend" Text="发送" runat="server" /></td>
</tr>
</table>
</form>
</body>
</HTML>using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Web.Mail;namespace mail
{ public class SendMail1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label lblShowMsg;
protected System.Web.UI.WebControls.TextBox tbTo;
protected System.Web.UI.WebControls.TextBox tbFrom;
protected System.Web.UI.WebControls.TextBox tbSubject;
protected System.Web.UI.WebControls.TextBox tbMsgText;
protected System.Web.UI.WebControls.Button btnSend;
private void Page_Load(object sender, System.EventArgs e)
{ } #region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{ InitializeComponent();
base.OnInit(e);
}
private void InitializeComponent()
{
this.btnSend.Click += new System.EventHandler(this.btnSend_Click);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion private void btnSend_Click(object sender, System.EventArgs e)
{
//分别取得邮件的发信人、收信人、主题以及邮件主体等信息
string strFrom = tbFrom.Text;
string strTo = tbTo.Text;
string strSubject = tbSubject.Text;
string strMsgText = tbMsgText.Text;
try
{
SmtpMail.SmtpServer = "smtp.sina.com.cn";
SmtpMail.Send(strFrom,strTo,strSubject,strMsgText);
//清除Label控件中的内容
tbTo.Text = "";
tbSubject.Text = "";
tbMsgText.Text = "";
lblShowMsg.Text = "发送至<b>"+strTo+"</b>邮件,发送成功";
}
catch(Exception ee)
{
lblShowMsg.Text = "发送邮件失败:"+ee.ToString();
}
} }
}
SmtpMail
MailAttachment