欢迎来到天天文库
浏览记录
ID:27884246
大小:219.00 KB
页数:21页
时间:2018-12-06
《c#邮件群发系统设计代码解析》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、邮件群发系统代码解析20112011/1/14Blog:xiaoyaosr.blog.51cto.com
2、逍遥散人Xiaoyaosr邮件群发系统代码解析作者:逍遥散人Blog:http://xiaoyaosr.blog.51cto.com邮件群发系统代码解析2011概要:子线程工作,发送成功邮件做标记,逐条提取数据,气泡提示信息,最小化到托盘,实时进度条代码:usingSystem;usingSystem.Collections;usingSystem.Collections.Generic;usi
3、ngSystem.ComponentModel;usingSystem.Data;usingSystem.Data.OleDb;usingSystem.Threading;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.Net.Mail;usingSystem.Net;usingSystem.Text.RegularExpressions;namespaceMailGroupSends{publicpartialclassForm1:Fo
4、rm{publicForm1(){InitializeComponent();}privatestringsubject=string.Empty;privatestringmailto=string.Empty;privatestringbody=string.Empty;privateintsucNum=0;privateintTotalDate{get{if(this.txtDateCount.Text.Trim().Length>0)returnConvert.ToInt32(this.tx
5、tDateCount.Text.Trim());return4;}set{this.txtDateCount.Text=value.ToString();}}privatestringConnString作者:逍遥散人Blog:http://xiaoyaosr.blog.51cto.com邮件群发系统代码解析2011{get{stringpathFull=System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;string
6、path=pathFull.Substring(0,pathFull.LastIndexOf(@""));return@"Provider=Microsoft.Jet.OLEDB.4.0;DataSource="+path+@"mail.mdb";}}privateboolmailSent=false;//邮件是否发送成功privateintmailTotalCount=0;privateintCategoryId=0;privateintSentCount=0;//已发送数privateint
7、UnitConversion=1;//默认为秒//////发送间隔///privateintInterval{get{inttimer=0;inttotalMis=(TotalDate*UnitConversion*1000);timer=totalMis/(mailTotalCount-SentCount);returntimer;}}//////提取邮件///privatevoidInitMailList(){OleDb
8、ConnectionConn=newOleDbConnection(ConnString);try{stringstrWhere=CategoryId==1000?"":"andcategoryid="+CategoryId+"orderbyisSend,uyx";stringsqlStr=@"selecttop1uyxfrom[usermail]whereisDelete=0andIsSend=0"+strWhere;if(Conn.State==ConnectionState.Closed)Co
9、nn.Open();作者:逍遥散人Blog:http://xiaoyaosr.blog.51cto.com邮件群发系统代码解析2011OleDbCommandcmd=newOleDbCommand(sqlStr,Conn);OleDbDataReaderreader=cmd.ExecuteReader();mailto=string.Empty;while(reader.Read()){mailto+=reader[0].ToString()+",";}reader.
此文档下载收益归作者所有