Sql Server Job VBScript Send Mail
来源:互联网 发布:淘宝孕妇装推荐 编辑:程序博客网 时间:2024/05/23 18:55
Dim jmail,mailBody,fs,txtfs,strsql,strdate
Dim Conn,RsName,strename,strw,strm,rw,strpcp,RsAssis,dtetodate
Dim inttoday
dtetodate=dateadd("d",Date,0)
inttoday = Year(dtetodate)*10000+Month(dtetodate)*100+Day(dtetodate)
set Conn = CreateObject ("ADODB.Connection")
Conn.Open "Provider=MSDataShape; DATA PROVIDER=SQLOLEDB.1;Password=*****;Persist Security Info=True;User ID=***;Initial Catalog=***;Data Source=***"
strsql="exec usp_***** 3"
set RsName=Conn.Execute(strsql)
if not RsName.eof then
do while not RsName.eof
strdeptlist = "<tr><td align=center height=30>申请单</td><td align=center>" & RsName("form_no") & "</td><td align=center>" & RsName("app_name") & "</td><td align=center>" & RsName("datein") & "</td></tr>"
Set jmail = CreateObject("JMail.Message")
strmail=Rtrim(RsName("mail_account"))
strdte=Rtrim(RsName("datein"))
strtype=Rtrim(RsName("absence_des"))
strlogin_name=Rtrim(RsName("login_name"))
strcode=Rtrim(RsName("dept_code"))
strformno=Rtrim(RsName("form_no"))
strappname=Rtrim(RsName("app_name"))
strsql1="select mail_account from am_employee a,RL_DMS_SECURITY1 b where b.emp_id=a.emp_id and conditions like '%" & strcode & "%' and convert(nchar(10),due_date,112)>'"&inttoday&"' and active='y'"
set RsAssis=Conn.Execute(strsql1)
if not RsAssis.eof Then
strml=Rtrim(RsAssis("mail_account"))
jmail.AddRecipient strml
end if
jmail.AddRecipientCC "**@***.com"
set fs = CreateObject("Scripting.FileSystemObject")
set txtf = fs.OpenTextFile("\\**\mail\T***_applicant.htm")
mailBody = ""
if not txtf.atEndOfStream then
mailBody = txtf.ReadAll
end if
mailBody = replace(mailBody,"##todate##",strdte)
mailBody = replace(mailBody,"##type##",strtype)
mailBody = replace(mailBody,"##event##",strdeptlist)
mailBody = replace(mailBody,"##name##",strlogin_name)
jmail.From = "****@qisda.com"
jmail.FromName="***"
jmail.Logging = True
jmail.Silent = True
jmail.ContentType = "text/html"
jmail.Charset = "GB2312"
jmail.Subject = "提醒您手续未完成"
jmail.Body = ""
jmail.HTMLBody=mailBody
jmail.Send("******")
set jmail = Nothing
set RsAssis=nothing
set fs = Nothing
RsName.movenext
Loop
end if
set Conn = Nothing
Dim Conn,RsName,strename,strw,strm,rw,strpcp,RsAssis,dtetodate
Dim inttoday
dtetodate=dateadd("d",Date,0)
inttoday = Year(dtetodate)*10000+Month(dtetodate)*100+Day(dtetodate)
set Conn = CreateObject ("ADODB.Connection")
Conn.Open "Provider=MSDataShape; DATA PROVIDER=SQLOLEDB.1;Password=*****;Persist Security Info=True;User ID=***;Initial Catalog=***;Data Source=***"
strsql="exec usp_***** 3"
set RsName=Conn.Execute(strsql)
if not RsName.eof then
do while not RsName.eof
strdeptlist = "<tr><td align=center height=30>申请单</td><td align=center>" & RsName("form_no") & "</td><td align=center>" & RsName("app_name") & "</td><td align=center>" & RsName("datein") & "</td></tr>"
Set jmail = CreateObject("JMail.Message")
strmail=Rtrim(RsName("mail_account"))
strdte=Rtrim(RsName("datein"))
strtype=Rtrim(RsName("absence_des"))
strlogin_name=Rtrim(RsName("login_name"))
strcode=Rtrim(RsName("dept_code"))
strformno=Rtrim(RsName("form_no"))
strappname=Rtrim(RsName("app_name"))
strsql1="select mail_account from am_employee a,RL_DMS_SECURITY1 b where b.emp_id=a.emp_id and conditions like '%" & strcode & "%' and convert(nchar(10),due_date,112)>'"&inttoday&"' and active='y'"
set RsAssis=Conn.Execute(strsql1)
if not RsAssis.eof Then
strml=Rtrim(RsAssis("mail_account"))
jmail.AddRecipient strml
end if
jmail.AddRecipientCC "**@***.com"
set fs = CreateObject("Scripting.FileSystemObject")
set txtf = fs.OpenTextFile("\\**\mail\T***_applicant.htm")
mailBody = ""
if not txtf.atEndOfStream then
mailBody = txtf.ReadAll
end if
mailBody = replace(mailBody,"##todate##",strdte)
mailBody = replace(mailBody,"##type##",strtype)
mailBody = replace(mailBody,"##event##",strdeptlist)
mailBody = replace(mailBody,"##name##",strlogin_name)
jmail.From = "****@qisda.com"
jmail.FromName="***"
jmail.Logging = True
jmail.Silent = True
jmail.ContentType = "text/html"
jmail.Charset = "GB2312"
jmail.Subject = "提醒您手续未完成"
jmail.Body = ""
jmail.HTMLBody=mailBody
jmail.Send("******")
set jmail = Nothing
set RsAssis=nothing
set fs = Nothing
RsName.movenext
Loop
end if
set Conn = Nothing
- Sql Server Job VBScript Send Mail
- SQL SERVER – 2008 – Configure Database Mail – Send Email From SQL Database
- How to send mail using VBScript & JMail - SourceCode - 如何用VBScript & JMail 发送邮件 - 源码
- Power shell Send mail by exchanges server
- send mail by SMTP server (Python)
- Sql Server Send Email...
- ORACLE SEND MAIL WITH PL/SQL
- SQL SERVER Mail
- send Mail
- Send mail
- Send mail
- SEND MAIL
- send mail
- send mail
- send mail
- SEND MAIL
- sql server 创建job
- Send-only Mail Server with Exim on Ubuntu 11.04
- CentOS 6.2安装第三方软件库epel
- 不连续子数组和
- 编译包含double类型的cuda文件
- 十道海量数据处理面试题与十个方法大总结
- sipdroid的videocamera类,流程分析及RTP/RTCP介绍
- Sql Server Job VBScript Send Mail
- IIS错误:•Managed handler is used; however, ASP.NET is not installed or is not installed completely.
- CListCtrl控件部分
- jquery如何判断checkbox(复选框)是否被选中
- Android home键和back键区别
- cjdbc常有异常总结
- build打包
- 创业指南:不该违反的9条军规
- struts2的配置