怎样用 .NET实现邮件发送 我正在学习C#网络编程,现在在研究怎样实现发送邮件的功能! 研究了一段时间还是实现不了,请各位高手多多指教。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://blog.csdn.net/lff642/archive/2008/07/15/2654346.aspx protected void Button1_Click(object sender, EventArgs e) { //创建一个新邮件 jmail.MessageClass message = new MessageClass(); //设置邮件的编码格式为中文 message.Charset = "gb2312"; //邮件的发送者 message.From = txtsendmail.Text; //邮件的发送者显示的名字 message.FromName = txtsendname.Text; //邮件的主题 message.Subject = subject.Text; //邮件的内容 message.Body = txtcontent.Text; //邮件服务器的验证名称和密码 message.MailServerUserName = txtValidatename.Text; message.MailServerPassWord = txtValidatepass.Text; //添加附件 //判断是否选择了文件 if (FileUpload1.PostedFile.FileName != "") { //文件的路径 string filepath = FileUpload1.PostedFile.FileName; //添加到邮件的附件中 message.AddAttachment(filepath, true, "text/html"); } //邮件的接收人 message.AddRecipient(txtreceive.Text, "", ""); //发送参数是邮件的服务器,不同邮件地址、服务器肯定不同 message.Send(smtp.Text, false); //提示信息 Response.Write("<script language='javascript'> alert('发送成功');</script>"); }} 这个都帖得不想帖了有W个人的博客里有这些东西了。。LZ自己搜一下。。 http://www.cnblogs.com/hymxtang/archive/2007/06/27/797247.html这个里面说的蛮多的,从基础的说起 http://blog.csdn.net/hb_gx/archive/2008/04/16/2298945.aspx//用 System.Web.Mail 的写法MailMessage mail = new MailMessage();mail.To = txtMailTo.Text; //收件人,多个收件人用 ; 号隔开,很是灵活mail.Subject = txtSubject.Text; //主题mail.Body = txtBody.Text; //内容mail.BodyFormat = MailFormat.Html;mail.Priority = MailPriority.Normal;//显示的发件人mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendemailaddress", "[email protected]");//实际发件人mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpaccountname", "[email protected]");//用户名mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "hbgx");//密码mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "xgbh");mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //验证级别SmtpMail.SmtpServer = "smtp.hotmail.com";SmtpMail.SmtpServer.Insert(0, "smtp.hotmail.com");SmtpMail.Send(mail);本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/hb_gx/archive/2008/04/16/2298945.aspx 【小白电脑前坐等高手答复】Gridview下载和删除 C#怎样点击窗体的关闭时让窗体隐藏,不是关闭 主窗体弹出一个新窗体后,主窗体的线程还能起作用吗? 用Object.GetType获得类型名称,那么如何创建? 如何从oracle的blob字段中取出html格式的table C# 连接外网ACCESS 谁知道怎么设置字符串的编码属性啊?给点代码.谢谢拉 一个简单的打印设置问题, 登陆模块的构建 高手救命!!! C#的6种常用集合类大比拼 关于C#中panel重画问题
{
//创建一个新邮件
jmail.MessageClass message = new MessageClass();
//设置邮件的编码格式为中文
message.Charset = "gb2312";
//邮件的发送者
message.From = txtsendmail.Text;
//邮件的发送者显示的名字
message.FromName = txtsendname.Text;
//邮件的主题
message.Subject = subject.Text;
//邮件的内容
message.Body = txtcontent.Text;
//邮件服务器的验证名称和密码
message.MailServerUserName = txtValidatename.Text;
message.MailServerPassWord = txtValidatepass.Text;
//添加附件
//判断是否选择了文件
if (FileUpload1.PostedFile.FileName != "")
{
//文件的路径
string filepath = FileUpload1.PostedFile.FileName;
//添加到邮件的附件中
message.AddAttachment(filepath, true, "text/html");
}
//邮件的接收人
message.AddRecipient(txtreceive.Text, "", "");
//发送参数是邮件的服务器,不同邮件地址、服务器肯定不同
message.Send(smtp.Text, false);
//提示信息
Response.Write("<script language='javascript'> alert('发送成功');</script>"); }
}
这个都帖得不想帖了有W个人的博客里有这些东西了。。LZ自己搜一下。。
MailMessage mail = new MailMessage();
mail.To = txtMailTo.Text; //收件人,多个收件人用 ; 号隔开,很是灵活
mail.Subject = txtSubject.Text; //主题
mail.Body = txtBody.Text; //内容
mail.BodyFormat = MailFormat.Html;
mail.Priority = MailPriority.Normal;
//显示的发件人
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendemailaddress", "[email protected]");
//实际发件人
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpaccountname", "[email protected]");
//用户名
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "hbgx");
//密码
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "xgbh");
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //验证级别SmtpMail.SmtpServer = "smtp.hotmail.com";
SmtpMail.SmtpServer.Insert(0, "smtp.hotmail.com");
SmtpMail.Send(mail);
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/hb_gx/archive/2008/04/16/2298945.aspx