asp.net带附件功能的简单发送邮件
<div>
收件人:<asp:TextBox ID="txt_toman" runat="server"></asp:TextBox>
<br />
主题:<asp:TextBox ID="txt_title" runat="server"></asp:TextBox>
<br />
内容:<asp:TextBox ID="txt_content" runat="server" Height="66px"
TextMode="MultiLine" Width="194px"></asp:TextBox>
<br />
附件:<asp:FileUpload ID="FileUpload1" runat="server" />
<br />
<asp:Button ID="btn_send" runat="server" onclick="btn_send_Click"
Text=" Send " />
<asp:Label ID="lbl_mag" runat="server" ForeColor="Red"></asp:Label>
</div>
view plain
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;
using System.Text;
namespace WebApplication1
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btn_send_Click(object sender, EventArgs e)
{
bool flag = SendMail("发信人地址", "发信人", "用户名", "密码", txt_title.Text, txt_content.Text, txt_toman.Text, FileUpload1);
if (flag)
{
lbl_mag.Text = "发送成功";
}
else
{
lbl_mag.Text = "糟糕,发送失败啦!";
}
}
/// <summary>
/// 简单邮件发送器
/// </summary>
/// <param name="user">发信人地址</param>
&
相关新闻>>
- 发表评论
-
- 最新评论 更多>>