求:系统自动发邮件代码,高手快来哈!SOS 我想做用户注册,管理员审核用户信息后帐号开通,系统自动发邮件通知用户,ASP.NET代码?,万分感谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 using System.Net.Mail;using System.Net.Mime;using System.Net;public class EMail{ public static string From; public static string To; public static string Subject; public static string Body; public static bool HasAttachment; public static string AttachmentPath; public static MailMessage msg; public static SmtpClient client; public static string UseName; public static string Pwd; public static string SmtpServer; //创建Mail public static void CreateMail() { msg = new MailMessage( From, To, Subject, Body); } //创建附件 public static void CreateMailAttachment() { Attachment Atta = new Attachment(AttachmentPath, MediaTypeNames.Application.Octet); //ContentDisposition disposition = Atta.ContentDisposition; //disposition.CreationDate = System.IO.File.GetCreationTime(AttachmentPath); //disposition.ModificationDate = System.IO.File.GetLastWriteTime(AttachmentPath); //disposition.ReadDate = System.IO.File.GetLastAccessTime(AttachmentPath); msg.Attachments.Add(Atta); } //创建协议 public static void CreateSmtp() { client = new SmtpClient(); client.Credentials = new NetworkCredential(UseName, Pwd); client.Port = 587;//Gmail使用的端口 client.Host = SmtpServer; client.EnableSsl = true;//经过ssl加密 } //发送mail public static void SendMail() { CreateMail(); if (HasAttachment == true) { CreateMailAttachment(); } CreateSmtp(); client.Send(msg); }}可以把上边的代码放到你的按钮点击事件里:试试~~ 问个关于添加数据的问题 ASP.NET URL重写 请问如何把从数据库读出的数据写到数组中 什么是伪表态技术 sql 查询时间问题 对权限的控制,控制到页面的按钮(DNN) 没分了,一个页面,包含一个iframe,如何刷新页面时不刷新iframe内的页面? html传过来控件的值(是中文的),我在APS.NET里面接到的是乱码,有什么方法可以解决。 关于类型转换的问题`````请大家帮帮忙 如何将基于console的程序转化为web程序 邮件发送问题 页面怎么调用后台数据
using System.Net.Mail;
using System.Net.Mime;
using System.Net;public class EMail
{
public static string From;
public static string To;
public static string Subject;
public static string Body;
public static bool HasAttachment;
public static string AttachmentPath;
public static MailMessage msg;
public static SmtpClient client;
public static string UseName;
public static string Pwd;
public static string SmtpServer; //创建Mail
public static void CreateMail()
{
msg = new MailMessage(
From,
To,
Subject,
Body);
}
//创建附件
public static void CreateMailAttachment()
{
Attachment Atta = new Attachment(AttachmentPath, MediaTypeNames.Application.Octet); //ContentDisposition disposition = Atta.ContentDisposition;
//disposition.CreationDate = System.IO.File.GetCreationTime(AttachmentPath);
//disposition.ModificationDate = System.IO.File.GetLastWriteTime(AttachmentPath);
//disposition.ReadDate = System.IO.File.GetLastAccessTime(AttachmentPath); msg.Attachments.Add(Atta);
}
//创建协议
public static void CreateSmtp()
{
client = new SmtpClient();
client.Credentials = new NetworkCredential(UseName, Pwd);
client.Port = 587;//Gmail使用的端口
client.Host = SmtpServer;
client.EnableSsl = true;//经过ssl加密
}
//发送mail
public static void SendMail()
{
CreateMail(); if (HasAttachment == true)
{
CreateMailAttachment();
}
CreateSmtp(); client.Send(msg);
}
}
可以把上边的代码放到你的按钮点击事件里:
试试~~