代码语言
.
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
/
698
前臺全部代碼: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="MailPJQGD.aspx.cs" Inherits="MailPJQGD" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>无标题页</title> <style type="text/css"> .style1 { width: 100%; } </style> </head> <body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:Timer ID="Timer1" runat="server" ontick="Timer1_Tick"> </asp:Timer> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> </ContentTemplate> </asp:UpdatePanel> </div> </form> </body> </html> 后臺代碼: 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.Data.SqlClient; using System.Net.Mail; public partial class MailPJQGD : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } //public void SendMail(string strSmtpServer, string UserName, string Password, string strFrom, string strto, string strSubject, string strBody) public void SendSMTPEMail(string strSmtpServer, string strFrom, string strFromPass, string strto, string strSubject, string strBody) { //生成一個使用Smtp發送郵件的客戶端對象; System.Net.Mail.SmtpClient Client = new SmtpClient(strSmtpServer); Client.Port = 25; Client.UseDefaultCredentials = false;//表示以当前登录用户的默认凭据进行身份验证 //Client.Credentials = new System.Net.NetworkCredential(UserName, Password); 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); //发送 } public static int iii = 0; protected void Timer1_Tick(object sender, EventArgs e) { if (iii == 0) { string day = DateTime.Now.Day.ToString(); if (day == "15") { string server = "192.168.2.8";//定义服务器地址 string sendEmail = "mis10@tjpcb.com";//定义发件人邮箱 string sendEmailPassWord = "123456";//定义发件人邮箱密码 string getEmail = "lishuanzhu@tjpcb.com";//获取收件人的邮箱地址 string titleEmail = "配件請購單需務數量明細導出";//定义邮件的主题 string context = "";//定义邮件的内容 string str = "server=192.168.3.127;database=FlowMaster;UId=sa;password=bruce_zhao888418"; SqlConnection sqlcon = new SqlConnection(str); sqlcon.Open(); string sqlstr = @" select distinct * from ( select nows,ApplyerDeptName,pinming1,norm1,Material1,quantity1 from WLQGD_View where applydatetime>='2010-8-15' and applydatetime<='2010-9-14' and Status = '100' and (quantity1<>'0' and quantity1 is not null and quantity1<>'' and pinming1<>'' and pinming1 is not null) union all select nows,ApplyerDeptName,pinming2,norm2,Material2,quantity2 from WLQGD_View where applydatetime>='2010-8-15' and applydatetime<='2010-9-14' and Status = '100' and (quantity2<>'0' and quantity2 is not null and quantity2<>'' and pinming2<>'' and pinming2 is not null) union all select nows,ApplyerDeptName,pinming3,norm3,Material3,quantity3 from WLQGD_View where applydatetime>='2010-8-15' and applydatetime<='2010-9-14' and Status = '100' and (quantity3<>'0' and quantity3 is not null and quantity3<>'' and pinming3<>'' and pinming3 is not null) union all select nows,ApplyerDeptName,pinming4,norm4,Material4,quantity4 from WLQGD_View where applydatetime>='2010-8-15' and applydatetime<='2010-9-14' and Status = '100' and (quantity4<>'0' and quantity4 is not null and quantity4<>'' and pinming4<>'' and pinming4 is not null) union all select nows,ApplyerDeptName,pinming5,norm5,Material5,quantity5 from WLQGD_View where applydatetime>='2010-8-15' and applydatetime<='2010-9-14' and Status = '100' and (quantity5<>'0' and quantity5 is not null and quantity5<>'' and pinming5<>'' and pinming5 is not null) union all select nows,ApplyerDeptName,pinming6,norm6,Material6,quantity6 from WLQGD_View where applydatetime>='2010-8-15' and applydatetime<='2010-9-14' and Status = '100' and (quantity6<>'0' and quantity6 is not null and quantity6<>'' and pinming6<>'' and pinming6 is not null) union all select nows,ApplyerDeptName,pinming7,norm7,Material7,quantity7 from WLQGD_View where applydatetime>='2010-8-15' and applydatetime<='2010-9-14' and Status = '100' and (quantity7<>'0' and quantity7 is not null and quantity7<>'' and pinming7<>'' and pinming7 is not null) union all select nows,ApplyerDeptName,pinming8,norm8,Material8,quantity8 from WLQGD_View where applydatetime>='2010-8-15' and applydatetime<='2010-9-14' and Status = '100' and (quantity8<>'0' and quantity8 is not null and quantity8<>'' and pinming8<>'' and pinming8 is not null) )A order by nows asc "; SqlDataAdapter sqlda = new SqlDataAdapter(sqlstr, sqlcon); DataSet ds = new DataSet(); string tableStr = @"<table border='0' cellpadding='0' cellspacing='0' style='font-family:宋体; font-size:14px; color:Blue;'> <tr><td>您好:</td></tr> <tr><td> 如下為2010-8-15至2010-9-14日,請購單需備數量明細,請收悉!</td></tr> </table><br/><table border='0' cellpadding='0' cellspacing='0' style='font-family:宋体; font-size:14px; color:Blue;' align='left'> <tr><td>軟硬體維護組 敬呈 </td></tr> </table><br/><br/><table border='1' cellpadding='0' cellspacing='0' align='left'> <tr style='color: #FFFFFF;background-color: #FF9900;' align='center'><td>填单时间</td><td>申請課別</td><td>品名</td><td>規格</td><td>品牌材質</td><td>需備數量</td></tr>"; sqlda.Fill(ds); if (ds.Tables[0].Rows.Count > 0) { for (int i = ds.Tables[0].Rows.Count; i > 0; i--) { string nows = ds.Tables[0].Rows[i - 1][0].ToString(); string ApplyDepName=ds.Tables[0].Rows[i - 1][1].ToString(); string pingming1 = ds.Tables[0].Rows[i - 1][2].ToString(); string norm1 = ds.Tables[0].Rows[i - 1][3].ToString(); string Material1= ds.Tables[0].Rows[i - 1][4].ToString(); string quantity1 = ds.Tables[0].Rows[i-1][5].ToString(); tableStr += @" <tr align='center'><td style='font-size:12px;width:200px;'>" + nows + @"</td><td style='font-size:12px;width:200px;'>" + ApplyDepName + @"</td><td style='font-size:12px;width:200px;'>" + pingming1 + @"</td><td style='font-size:12px;width:200px;'>" + norm1 + @" </td><td style='font-size:12px;width:200px;'>" + Material1 + @" </td><td style='font-size:12px;width:200px;'>" + quantity1 + @"</td></tr> "; } tableStr += @"</table>"; SendSMTPEMail(server, sendEmail, sendEmailPassWord, getEmail, "配件請購單需務數量明細導出", tableStr); SendSMTPEMail(server, sendEmail, sendEmailPassWord, "mis12@tjpcb.com", titleEmail, tableStr); SendSMTPEMail(server, sendEmail, sendEmailPassWord, "qianshengjun@tjpcb.com", titleEmail, tableStr); } } iii++; Label1.Text = "success"; } } }
试试其它关键字
提醒功能
同语言下
.
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