asp.net Jmail表单提交发送邮件成功例子

luyangyy 2012-03-14 04:28:46
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Model;
using BLL;

public partial class Show_Msg : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void btnADD_Click(object sender, EventArgs e)
{
string msgType = this.ddlType.SelectedItem.Value;
string msgContent = this.txtMsgContent.Text;
string tel = this.txtTel.Text;
string msgmail = this.txtMail.Text;

Msg msg = new Msg();
msg.MsgType = msgType;
msg.MsgContent = msgContent;
msg.MsgTel = tel;
msg.MsgMail = msgmail;

if (msgManage.AddMsg(msg))
{

jmail.Message mail = new jmail.Message();
string subject = msgContent.Substring(0, 5) + "...";
string frommail = "111111111@163.com";
string tomail = "2222222@qq.com";
//silent属性:如果设置为true,jmail不会抛出例外错误. jmail. send( () 会根据操作结果返回true或false
mail.Silent = true;
//jmail创建的日志,前提loging属性设置为true
mail.Logging = true;
//字符集,缺省为"us-ascii"
mail.Charset = "gb2312";

mail.AddRecipient(tomail, "", "");
mail.From = frommail;
//发件人邮件用户名
mail.MailServerUserName = "luyangt";
//发件人邮件密码
mail.MailServerPassWord = "why1979524";
//设置邮件标题
mail.Subject = subject;
//邮件内容
mail.Body = "网站有留言:\n" + "留言类别:" + msgType +"\n留言信息:"+ msgContent;
mail.Body += "\n留言人联系方式:\n tel:" + tel + "\n E-Mail: " + msgmail;
mail.Body += "\n详细信息请登录网站了解http://12312321.com";
//jmail发送的方法
if (mail.Send("smtp.163.com", false))
{
Response.Write("<script>alert('提交成功')</script>");
}
else
{
Response.Write("<script>alert('系统忙请重新提交')</script>");
}
mail.Close();
//this.TextBox5.Text = string.Empty;

//Response.Write("<script>alert('提交成功')</script>");
}
else
{
Response.Write("<script>alert('提交失败')</script>");
}
}
}
...全文
100 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
SomethingJack 2012-03-14
  • 打赏
  • 举报
回复
虽然不知道是什么 但是好厉害啊 !谢谢分享`
luyangyy 2012-03-14
  • 打赏
  • 举报
回复
jmail下载地址 ishare.iask.sina.com.cn/f/23510597.html
luyangyy 2012-03-14
  • 打赏
  • 举报
回复
?你说的什么意思
porschev 2012-03-14
  • 打赏
  • 举报
回复

Jmail发送邮件发享代码?
luyangyy 2012-03-14
  • 打赏
  • 举报
回复
使用时需要添加JMail.dll引用,首先需要安装jmail组件,需要的说声

62,268

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧