代码语言
.
CSharp
.
JS
Java
Asp.Net
C
MSSQL
PHP
Css
PLSQL
Python
Shell
EBS
ASP
Perl
ObjC
VB.Net
VBS
MYSQL
GO
Delphi
AS
DB2
Domino
Rails
ActionScript
Scala
代码分类
文件
系统
字符串
数据库
网络相关
图形/GUI
多媒体
算法
游戏
Jquery
Extjs
Android
HTML5
菜单
网页交互
WinForm
控件
企业应用
安全与加密
脚本/批处理
开放平台
其它
【
Asp.Net
】
ASP.NET郵件按時間段進行發送
作者:
Dezai.CN
/ 发布于
2013/4/3
/
520
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 System.Threading; using System.Data.SqlClient; using System.Net.Mail; public partial class PJQGD : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } public void SendSMTPEMail(string strSmtpServer, string strFrom, string strFromPass, string strto, string strSubject, string strBody) { System.Net.Mail.SmtpClient client = new SmtpClient(strSmtpServer); client.UseDefaultCredentials = false; client.Credentials = new System.Net.NetworkCredential(strFrom, strFromPass); client.DeliveryMethod = SmtpDeliveryMethod.Network; System.Net.Mail.MailMessage message = new MailMessage(strFrom, strto, strSubject, strBody); message.BodyEncoding = System.Text.Encoding.UTF8; message.IsBodyHtml = true; client.Send(message); } protected void Timer1_Tick(object sender, EventArgs e) { string week = DateTime.Now.DayOfWeek.ToString();//獲取星期; if (week == "Sunday") //周日就不發送; { } else { int nowhour = Convert.ToInt32(DateTime.Now.Hour.ToString()); //獲取當前的小時數; if (nowhour == 8 || nowhour == 9 || nowhour == 10 || nowhour == 11 || nowhour == 12 || nowhour ==14 || nowhour == 15 || nowhour == 16 || nowhour == 17) { int it = 1; while (it < 1) { Thread.Sleep(1000); it++; } if (it == 1) { try { string str = "server=192.168.3.127;database=FlowMaster;UId=sa;password=bruce_zhao888418"; SqlConnection sqlcon = new SqlConnection(str); sqlcon.Open(); SqlDataAdapter sqlda = new SqlDataAdapter(@"select * FROM PJQGD_View with(updlock) WHERE (ApplyID = 'maintain' OR ApplyID = '00181' OR ApplyID = '01147' OR ApplyID = '02657') AND (nows >= '2010/7/13') AND (flag IS NULL or flag = '') AND (Step = 'CD02E866-68B4-47DF-9835-028AE56F7241') and 1=1", sqlcon); DataSet ds = new DataSet(); sqlda.Fill(ds); int num = ds.Tables[0].Rows.Count; if (num > 0) { for (int i = 0; i < num; i++) { string Subject = ds.Tables[0].Rows[i][6].ToString(); string explain = ds.Tables[0].Rows[i][7].ToString(); string pinming1 = ds.Tables[0].Rows[i][8].ToString(); string pinming2 = ds.Tables[0].Rows[i][9].ToString(); string pinming3 = ds.Tables[0].Rows[i][10].ToString(); string pinming4 = ds.Tables[0].Rows[i][11].ToString(); string pinming5 = ds.Tables[0].Rows[i][12].ToString(); string norm1 = ds.Tables[0].Rows[i][13].ToString(); string norm2 = ds.Tables[0].Rows[i][14].ToString(); string norm3 = ds.Tables[0].Rows[i][15].ToString(); string norm4 = ds.Tables[0].Rows[i][16].ToString(); string norm5 = ds.Tables[0].Rows[i][17].ToString(); string SequenceID=ds.Tables[0].Rows[i][18].ToString(); string server = "192.168.2.8";//定义服务器地址 string sendEmail = "mis10@tjpcb.com";//定义发件人邮箱 string sendEmailPassWord = "123456";//定义发件人邮箱密码 string getEmail = "sunny@tjpcb.com";//获取收件人的邮箱地址 string titleEmail = "統將配件請購單維護已填寫";//定义邮件的主题 string context = "表單流水號為:" + SequenceID +""+ "表單主旨:" + Subject + "" + "說明:" + explain + "" + "產品名1為:" + pinming1 + "產品規格:" + norm1 + "" + "產品名2為:" + pinming2 + "產品規格:" + norm2 + "" + "產品名3為:" + pinming3 + "產品規格:" + norm3 + "" + "產品名4為:" + pinming4 + "產品規格:" + norm4 + "<BR>" + "產品名5為:" + pinming5 + "產品規格:" + norm5;//定义邮件的内容 SendSMTPEMail(server, sendEmail, sendEmailPassWord, getEmail, titleEmail, context); SendSMTPEMail(server,sendEmail,sendEmailPassWord,"guojianghua@tjpcb.com",titleEmail,context); SendSMTPEMail(server, sendEmail, sendEmailPassWord, "gaohua@tjpcb.com", titleEmail, context); } string sqlstr = @"update PJQGD_View set flag='havingSend' where ((ApplyID='maintain') or (ApplyID='00181') or (ApplyID='01147') or (ApplyID='02657')) and (nows >='2010/7/13') and (Step='CD02E866-68B4-47DF-9835-028AE56F7241')"; SqlCommand cmd = new SqlCommand(sqlstr, sqlcon); cmd.ExecuteNonQuery(); } } catch (Exception er) { } } } } } }
试试其它关键字
按時間段進行發送
同语言下
.
gzip压缩
.
实现http多线程断点续传下载文件
.
实现多线程断点续传下载大文件
.
生成字符串的 CheckSum
.
根据 UserAgent 获取浏览器的类型和版本
.
根据 Agent 判断是否是智能手机
.
隐藏手机号中间四位为*方法
.
合并图片(二维码和其他图片合并)
.
ASP.NET CORE中判断是否移动端打开网页
.
ASP.NET(C#)实现页面计时(定时)自动跳转
可能有用的
.
C#实现的html内容截取
.
List 切割成几份 工具类
.
SQL查询 多列合并成一行用逗号隔开
.
一行一行读取txt的内容
.
C#动态修改文件夹名称(FSO实现,不移动文件)
.
c# 移动文件或文件夹
.
c#图片添加水印
.
Java PDF转换成图片并输出给前台展示
.
网站后台修改图片尺寸代码
.
处理大图片在缩略图时的展示
Dezai.CN
贡献的其它代码
(
4037
)
.
多线程Socket服务器模块
.
生成随机密码
.
清除浮动样式
.
弹出窗口居中
.
抓取url的函数
.
使用base HTTP验证
.
div模拟iframe嵌入效果
.
通过header转向的方法
.
Session操作类
.
执行sqlite输入插入操作后获得自动编号的ID
Copyright © 2004 - 2024 dezai.cn. All Rights Reserved
站长博客
粤ICP备13059550号-3