vbscript logparser的ISA2004 Web流量报告
程序员文章站
2022-08-27 14:50:35
很喜欢这里的学习气氛,也很佩服两位版主的技术水平,希望能够在这里与大家多多交流。 作为见面礼吧,把前一阵子写的一个生成isa 2004 web 流量报告的脚本与大家分享。说...
很喜欢这里的学习气氛,也很佩服两位版主的技术水平,希望能够在这里与大家多多交流。
作为见面礼吧,把前一阵子写的一个生成isa 2004 web 流量报告的脚本与大家分享。说明下,该校本是首发而且仅发在这里,我没有在菊花里面或任何地方发过。大家可以随意更改脚本以便适合你的要求,转载请保留作者信息谢谢。
我的很多客户希望能够每天或每周得到一份员工浏览web情况的报告,例如所访问的站点以及流量等等,他们都使用isa2004作为web proxy。由于isa2004自带的report不能满足他们的要求,所以我写了这个脚本,用来生成报告。使用前请先阅读readme.txt
'isa 2004 web log query tool
'created by mwpq
'version 1.0
'date 2007.9.18
on error resume next
dim startdate, enddate
dim topweb, topuser,usertop, usertopweb
'configuration part of the script
'==================================================================
startdate = 1 ' the newest log files to be queried. 1 means one day ago
interday = 7 ' the oldest log files is startdate + interday
' for example startdate =1, interday =7 means script will query log files between 8 days ago and yesterday's.
topweb="top 20" ' list top 20 websites visited. just change 20 to other no to get what you want like "top 21" will list top 21 websites.
topuser="top 10" ' list top 10 users and their total usage.
usertop = "top 20" ' list top 20 users with their top websites, depend on uesrtopweb. set to "" to list all users web usage
usertopweb = "top 10"
smailto = "mwpq@yahoo.com" 'send email repor to
smailfrom = "admin@yourdomain.com 'email comes from
smailsub = "isa web traffic report" 'email title
ssmtpserver = "youremailserver" 'email server
strmessage = "please see attachment for the isa web traffic report." 'email txt body.
satt = "c:\program files\microsoft isa server\isalogs\report.htm" 'email attachment path. the report.htm will be created under isa's log folder.
'===================================================================
const cdosendusingmethod = "http://schemas.microsoft.com/cdo/configuration/sendusing", _
cdosendusingport = 2, _
cdosmtpserver = "http://schemas.microsoft.com/cdo/configuration/smtpserver"
'create the html reprot and write the html header
'=================================================================================================================
const begin_table = " <table width=100% border=0 cellspacing=1 cellpadding=2>"
const end_table = " </table>"
const forreading = 1
const forwriting = 2
const forappending = 8
set ofso = createobject("scripting.filesystemobject")
if ofso.fileexists(".\report.htm") then
ofso.deletefile(".\report.htm")
end if
if ofso.fileexists(".\tempsum.w3c") then
ofso.deletefile(".\tempsum.w3c")
end if
set ofile = ofso.opentextfile(".\report.htm", forwriting, true, true)
'write the html head to file suit for ie viewer.
ofile.writeline ("<html>" & vbcrlf & _
"<head>" & vbcrlf & _
"<title> isa web usage reports</title>" & vbcrlf & _
"<style type=""text/css"">" & vbcrlf)
ofile.writeline ("<!--" & vbcrlf & _
".title {font-family: verdana, arial, helvetica, sans-serif; font-size: 16px; font-weight: bold; color:'#0000cc'}" & vbcrlf & _
".head {font-family: verdana, arial, helvetica, sans-serif; font-size: 14px; font-weight: bold; color:'#ffffff'}" & vbcrlf & _
".category {font-family: verdana, arial, helvetica, sans-serif; font-size: 11px; font-weight: bold; color:'#ffffff'}" & vbcrlf & _
".result {font-family: verdana, arial, helvetica, sans-serif; font-size: 11px; color:'#000000'}" & vbcrlf & _
".alert {font-family: verdana, arial, helvetica, sans-serif; font-size: 11px; font-weight: bold; color:'#ff0000'}" & vbcrlf & _
"a {color: '#000066'; text-decoration:none;}" & vbcrlf & _
"a:hover {text-decoration:underline}" & vbcrlf & _
"-->" & vbcrlf)
ofile.writeline ("</style>" & vbcrlf & _
"</head>" & vbcrlf & _
"<body bgcolor=#ffffff>" & vbcrlf)
ofile.writeline "<p class = title> isa web traffic report - from "&date-startdate-interday&" to "&date-startdate
ofile.writeline "<p>"
'=================================================================================================================
'end of create html report header part
'build the log file name list
spath = ""
while interday >= 0
dtmdate = date - startdate - interday
'convert the current date to utc
'=================================================================================================================
strday = day(dtmdate)
if len(strday) < 2 then
strday = "0" & strday
end if
strmonth = month(dtmdate)
if len(strmonth) < 2 then
strmonth = "0" & strmonth
end if
stryear = year(dtmdate)
sdate = stryear & strmonth & strday
'=================================================================================================================
stemp2 = "'"&"isalog_"&sdate&"_web_* "&"'"
spath = spath & stemp2
if interday - startday > 0 then
spath = spath&", "
end if
interday = interday - 1
wend
'create a temp sumary file
set objlogparser = createobject("msutil.logquery")
set objinputformat = _
createobject("msutil.logquery.w3cinputformat")
set w3coutputformat = wscript.createobject("msutil.logquery.w3coutputformat")
w3coutputformat.filemode = 1 ' set file to overwrite mode
strquery = "select cs-username, r-host, sum(add(cs-bytes,sc-bytes)) as srdata into 'tempsum.w3c' from "&spath&" where sc-network = 'external' group by cs-username,r-host order by srdata desc"
objlogparser.executebatch strquery, objinputformat,w3coutputformat
'check tempsum.w3c existed
set ofso1 = createobject("scripting.filesystemobject")
if ofso1.fileexists(".\tempsum.w3c") then
ofso1 = nothing
else
ofso1=nothing
wscript.echo "sorry cannot find some of the log files to query! script quit."
wscript.quit
end if
'generate report based on temp file.
'================================================================================
'generate top web sites.
fl=0
ofile.writeline (begin_table & vbcrlf)
mwheading topweb&" websites"
mwbrow
mwtitle "site name"
mwtitle "traffic (mb)"
mwerow
set objlogparser10 = createobject("msutil.logquery")
set objinputformat10 = _
createobject("msutil.logquery.w3cinputformat")
'objinputformat.recurse = 2
strquery10 = "select "&topweb&" r-host, sum(srdata) as tsrdata from 'tempsum.w3c' group by r-host order by tsrdata desc"
set objrecordset10 = objlogparser10.execute(strquery10, objinputformat10)
do while not objrecordset10.atend
set objrecord10 = objrecordset10.getrecord
if fl = 0 then
mwbrow
mwdetail2 objrecord10.getvalue("r-host")
mwdetail2 formatnumber(objrecord10.getvalue("tsrdata")/1048576,2)
mwerow
fl=1
else
mwbrow
mwdetail1 objrecord10.getvalue("r-host")
mwdetail1 formatnumber(objrecord10.getvalue("tsrdata")/1048576,2)
mwerow
fl=0
end if
'wscript.echo "uri"& objrecord2.getvalue("r-host") & "---" & objrecord2.getvalue("srdata")
objrecordset10.movenext
loop
spacer(12)
ofile.writeline (end_table & vbcrlf)
'================================================================================
'================================================================================
'generate top user list.
fl=0
ofile.writeline (begin_table & vbcrlf)
mwheading topuser&" users list"
mwbrow
mwtitle "logon name"
mwtitle "traffic (mb)"
mwerow
set objlogparser11 = createobject("msutil.logquery")
set objinputformat11 = _
createobject("msutil.logquery.w3cinputformat")
'objinputformat.recurse = 2
strquery11 = "select "&topuser&" cs-username, sum(srdata) as tsrdata from 'tempsum.w3c' group by cs-username order by tsrdata desc"
set objrecordset11 = objlogparser11.execute(strquery11, objinputformat11)
do while not objrecordset11.atend
set objrecord11 = objrecordset11.getrecord
if fl=0 then
mwbrow
mwdetail2 objrecord11.getvalue("cs-username")
mwdetail2 formatnumber(objrecord11.getvalue("tsrdata")/1048576,2)
mwerow
fl =1
else
mwbrow
mwdetail1 objrecord11.getvalue("cs-username")
mwdetail1 formatnumber(objrecord11.getvalue("tsrdata")/1048576,2)
mwerow
fl =0
end if
'wscript.echo "uri"& objrecord2.getvalue("r-host") & "---" & objrecord2.getvalue("srdata")
objrecordset11.movenext
loop
spacer(12)
ofile.writeline (end_table & vbcrlf)
'================================================================================
set objlogparser1 = createobject("msutil.logquery")
set objinputformat1 = _
createobject("msutil.logquery.w3cinputformat")
strquery1 = "select "&usertop&" cs-username, sum(srdata) as tsrdata from 'tempsum.w3c' group by cs-username order by tsrdata desc"
set objrecordset1 = objlogparser1.execute(strquery1, objinputformat1)
ofile.writeline (begin_table & vbcrlf)
mwheading usertop&" users' web traffic "
do while not objrecordset1.atend
set objrecord1 = objrecordset1.getrecord
strusername = objrecord1.getvalue("cs-username")
stt = "'"&strusername&"'"
mwbrow
mwtitle strusername &" ------ total web traffic: " & formatnumber(objrecord1.getvalue("tsrdata")/1048576,2)&" mb"
mwtitle "traffic (mb)"
mwerow
'wscript.echo ""
'wscript.echo stt &" >>> data: " & objrecord1.getvalue("tsrdata")
set objlogparser2 = createobject("msutil.logquery")
set objinputformat2 = _
createobject("msutil.logquery.w3cinputformat")
'objinputformat.recurse = 2
fl=0
strquery2 = "select "&usertopweb&" r-host, srdata from 'tempsum.w3c' where cs-username =" &stt&" group by r-host,srdata"
set objrecordset2 = objlogparser2.execute(strquery2, objinputformat2)
do while not objrecordset2.atend
set objrecord2 = objrecordset2.getrecord
if fl=0 then
mwbrow
mwdetail2 objrecord2.getvalue("r-host")
mwdetail2 formatnumber(objrecord2.getvalue("srdata")/1048576,2)
mwerow
fl=1
else
mwbrow
mwdetail1 objrecord2.getvalue("r-host")
mwdetail1 formatnumber(objrecord2.getvalue("srdata")/1048576,2)
mwerow
fl=0
end if
'wscript.echo "uri"& objrecord2.getvalue("r-host") & "---" & objrecord2.getvalue("srdata")
objrecordset2.movenext
loop
objrecordset1.movenext
spacer(12)
loop
ofile.writeline (end_table & vbcrlf)
' write the html end to report.
ofile.writeline ("</body>")
ofile.writeline ("</html>")
ofile.close
'methods to create html(title and table) part
'=================================================================================================================
private sub mwheading(sheading)
ofile.writeline ( _
" <tr>" & vbcrlf & _
" <td colspan=7 bgcolor=#0099cc class=head>" & sheading &"</td>"& vbcrlf & _
" </tr>" & vbcrlf)
end sub
private sub mwtitle(scontent)
ofile.writeline ( _
" <td bgcolor=#0099ff align=left class=category height=14>" & scontent & "</td>" & vbcrlf)
end sub
private sub mwdetail1(scontent)
ofile.writeline ( _
" <td bgcolor=#dce3fc align=left class=result height=12>" & scontent & "</td>" & vbcrlf)
end sub
private sub mwdetail2(scontent)
ofile.writeline ( _
" <td bgcolor=#e9fbfe align=left class=result height=12>" & scontent & "</td>" & vbcrlf)
end sub
private sub mwalert1(scontent)
ofile.writeline ( _
" <td bgcolor=#dce3fc align=left class=alert height=12>" & scontent & "</td>" & vbcrlf)
end sub
private sub mwalert2(scontent)
ofile.writeline ( _
" <td bgcolor=#e9fbfe align=left class=alert height=12>" & scontent & "</td>" & vbcrlf)
end sub
private sub mwbrow
ofile.writeline ( " <tr>" & vbcrlf)
end sub
private sub mwerow
ofile.writeline ( " </tr>" & vbcrlf)
end sub
private sub spacer(iheight)
ofile.writeline ( _
" <tr><td height=" & iheight & "></td></tr>" & vbcrlf)
end sub
'=================================================================================================================
'end of create html method
'send email
dim imsg, iconf, flds
'// create the cdo connections.
set imsg = createobject("cdo.message")
set iconf = createobject("cdo.configuration")
set flds = iconf.fields
'// smtp server configuration.
with flds
.item(cdosendusingmethod) = cdosendusingport
'// set the smtp server address here.
.item(cdosmtpserver) = ssmtpserver
.update
end with
'// set the message properties.
with imsg
set .configuration = iconf
.to = smailto
.from = smailfrom
.subject = smailsub
.textbody = strmessage
end with
'imsg.htmlbody = smailmessage
'// send the message.
imsg.addattachment satt
imsg.send ' send the message.
set imsg = nothing
set iconf = nothing
作为见面礼吧,把前一阵子写的一个生成isa 2004 web 流量报告的脚本与大家分享。说明下,该校本是首发而且仅发在这里,我没有在菊花里面或任何地方发过。大家可以随意更改脚本以便适合你的要求,转载请保留作者信息谢谢。
我的很多客户希望能够每天或每周得到一份员工浏览web情况的报告,例如所访问的站点以及流量等等,他们都使用isa2004作为web proxy。由于isa2004自带的report不能满足他们的要求,所以我写了这个脚本,用来生成报告。使用前请先阅读readme.txt
复制代码 代码如下:
'isa 2004 web log query tool
'created by mwpq
'version 1.0
'date 2007.9.18
on error resume next
dim startdate, enddate
dim topweb, topuser,usertop, usertopweb
'configuration part of the script
'==================================================================
startdate = 1 ' the newest log files to be queried. 1 means one day ago
interday = 7 ' the oldest log files is startdate + interday
' for example startdate =1, interday =7 means script will query log files between 8 days ago and yesterday's.
topweb="top 20" ' list top 20 websites visited. just change 20 to other no to get what you want like "top 21" will list top 21 websites.
topuser="top 10" ' list top 10 users and their total usage.
usertop = "top 20" ' list top 20 users with their top websites, depend on uesrtopweb. set to "" to list all users web usage
usertopweb = "top 10"
smailto = "mwpq@yahoo.com" 'send email repor to
smailfrom = "admin@yourdomain.com 'email comes from
smailsub = "isa web traffic report" 'email title
ssmtpserver = "youremailserver" 'email server
strmessage = "please see attachment for the isa web traffic report." 'email txt body.
satt = "c:\program files\microsoft isa server\isalogs\report.htm" 'email attachment path. the report.htm will be created under isa's log folder.
'===================================================================
const cdosendusingmethod = "http://schemas.microsoft.com/cdo/configuration/sendusing", _
cdosendusingport = 2, _
cdosmtpserver = "http://schemas.microsoft.com/cdo/configuration/smtpserver"
'create the html reprot and write the html header
'=================================================================================================================
const begin_table = " <table width=100% border=0 cellspacing=1 cellpadding=2>"
const end_table = " </table>"
const forreading = 1
const forwriting = 2
const forappending = 8
set ofso = createobject("scripting.filesystemobject")
if ofso.fileexists(".\report.htm") then
ofso.deletefile(".\report.htm")
end if
if ofso.fileexists(".\tempsum.w3c") then
ofso.deletefile(".\tempsum.w3c")
end if
set ofile = ofso.opentextfile(".\report.htm", forwriting, true, true)
'write the html head to file suit for ie viewer.
ofile.writeline ("<html>" & vbcrlf & _
"<head>" & vbcrlf & _
"<title> isa web usage reports</title>" & vbcrlf & _
"<style type=""text/css"">" & vbcrlf)
ofile.writeline ("<!--" & vbcrlf & _
".title {font-family: verdana, arial, helvetica, sans-serif; font-size: 16px; font-weight: bold; color:'#0000cc'}" & vbcrlf & _
".head {font-family: verdana, arial, helvetica, sans-serif; font-size: 14px; font-weight: bold; color:'#ffffff'}" & vbcrlf & _
".category {font-family: verdana, arial, helvetica, sans-serif; font-size: 11px; font-weight: bold; color:'#ffffff'}" & vbcrlf & _
".result {font-family: verdana, arial, helvetica, sans-serif; font-size: 11px; color:'#000000'}" & vbcrlf & _
".alert {font-family: verdana, arial, helvetica, sans-serif; font-size: 11px; font-weight: bold; color:'#ff0000'}" & vbcrlf & _
"a {color: '#000066'; text-decoration:none;}" & vbcrlf & _
"a:hover {text-decoration:underline}" & vbcrlf & _
"-->" & vbcrlf)
ofile.writeline ("</style>" & vbcrlf & _
"</head>" & vbcrlf & _
"<body bgcolor=#ffffff>" & vbcrlf)
ofile.writeline "<p class = title> isa web traffic report - from "&date-startdate-interday&" to "&date-startdate
ofile.writeline "<p>"
'=================================================================================================================
'end of create html report header part
'build the log file name list
spath = ""
while interday >= 0
dtmdate = date - startdate - interday
'convert the current date to utc
'=================================================================================================================
strday = day(dtmdate)
if len(strday) < 2 then
strday = "0" & strday
end if
strmonth = month(dtmdate)
if len(strmonth) < 2 then
strmonth = "0" & strmonth
end if
stryear = year(dtmdate)
sdate = stryear & strmonth & strday
'=================================================================================================================
stemp2 = "'"&"isalog_"&sdate&"_web_* "&"'"
spath = spath & stemp2
if interday - startday > 0 then
spath = spath&", "
end if
interday = interday - 1
wend
'create a temp sumary file
set objlogparser = createobject("msutil.logquery")
set objinputformat = _
createobject("msutil.logquery.w3cinputformat")
set w3coutputformat = wscript.createobject("msutil.logquery.w3coutputformat")
w3coutputformat.filemode = 1 ' set file to overwrite mode
strquery = "select cs-username, r-host, sum(add(cs-bytes,sc-bytes)) as srdata into 'tempsum.w3c' from "&spath&" where sc-network = 'external' group by cs-username,r-host order by srdata desc"
objlogparser.executebatch strquery, objinputformat,w3coutputformat
'check tempsum.w3c existed
set ofso1 = createobject("scripting.filesystemobject")
if ofso1.fileexists(".\tempsum.w3c") then
ofso1 = nothing
else
ofso1=nothing
wscript.echo "sorry cannot find some of the log files to query! script quit."
wscript.quit
end if
'generate report based on temp file.
'================================================================================
'generate top web sites.
fl=0
ofile.writeline (begin_table & vbcrlf)
mwheading topweb&" websites"
mwbrow
mwtitle "site name"
mwtitle "traffic (mb)"
mwerow
set objlogparser10 = createobject("msutil.logquery")
set objinputformat10 = _
createobject("msutil.logquery.w3cinputformat")
'objinputformat.recurse = 2
strquery10 = "select "&topweb&" r-host, sum(srdata) as tsrdata from 'tempsum.w3c' group by r-host order by tsrdata desc"
set objrecordset10 = objlogparser10.execute(strquery10, objinputformat10)
do while not objrecordset10.atend
set objrecord10 = objrecordset10.getrecord
if fl = 0 then
mwbrow
mwdetail2 objrecord10.getvalue("r-host")
mwdetail2 formatnumber(objrecord10.getvalue("tsrdata")/1048576,2)
mwerow
fl=1
else
mwbrow
mwdetail1 objrecord10.getvalue("r-host")
mwdetail1 formatnumber(objrecord10.getvalue("tsrdata")/1048576,2)
mwerow
fl=0
end if
'wscript.echo "uri"& objrecord2.getvalue("r-host") & "---" & objrecord2.getvalue("srdata")
objrecordset10.movenext
loop
spacer(12)
ofile.writeline (end_table & vbcrlf)
'================================================================================
'================================================================================
'generate top user list.
fl=0
ofile.writeline (begin_table & vbcrlf)
mwheading topuser&" users list"
mwbrow
mwtitle "logon name"
mwtitle "traffic (mb)"
mwerow
set objlogparser11 = createobject("msutil.logquery")
set objinputformat11 = _
createobject("msutil.logquery.w3cinputformat")
'objinputformat.recurse = 2
strquery11 = "select "&topuser&" cs-username, sum(srdata) as tsrdata from 'tempsum.w3c' group by cs-username order by tsrdata desc"
set objrecordset11 = objlogparser11.execute(strquery11, objinputformat11)
do while not objrecordset11.atend
set objrecord11 = objrecordset11.getrecord
if fl=0 then
mwbrow
mwdetail2 objrecord11.getvalue("cs-username")
mwdetail2 formatnumber(objrecord11.getvalue("tsrdata")/1048576,2)
mwerow
fl =1
else
mwbrow
mwdetail1 objrecord11.getvalue("cs-username")
mwdetail1 formatnumber(objrecord11.getvalue("tsrdata")/1048576,2)
mwerow
fl =0
end if
'wscript.echo "uri"& objrecord2.getvalue("r-host") & "---" & objrecord2.getvalue("srdata")
objrecordset11.movenext
loop
spacer(12)
ofile.writeline (end_table & vbcrlf)
'================================================================================
set objlogparser1 = createobject("msutil.logquery")
set objinputformat1 = _
createobject("msutil.logquery.w3cinputformat")
strquery1 = "select "&usertop&" cs-username, sum(srdata) as tsrdata from 'tempsum.w3c' group by cs-username order by tsrdata desc"
set objrecordset1 = objlogparser1.execute(strquery1, objinputformat1)
ofile.writeline (begin_table & vbcrlf)
mwheading usertop&" users' web traffic "
do while not objrecordset1.atend
set objrecord1 = objrecordset1.getrecord
strusername = objrecord1.getvalue("cs-username")
stt = "'"&strusername&"'"
mwbrow
mwtitle strusername &" ------ total web traffic: " & formatnumber(objrecord1.getvalue("tsrdata")/1048576,2)&" mb"
mwtitle "traffic (mb)"
mwerow
'wscript.echo ""
'wscript.echo stt &" >>> data: " & objrecord1.getvalue("tsrdata")
set objlogparser2 = createobject("msutil.logquery")
set objinputformat2 = _
createobject("msutil.logquery.w3cinputformat")
'objinputformat.recurse = 2
fl=0
strquery2 = "select "&usertopweb&" r-host, srdata from 'tempsum.w3c' where cs-username =" &stt&" group by r-host,srdata"
set objrecordset2 = objlogparser2.execute(strquery2, objinputformat2)
do while not objrecordset2.atend
set objrecord2 = objrecordset2.getrecord
if fl=0 then
mwbrow
mwdetail2 objrecord2.getvalue("r-host")
mwdetail2 formatnumber(objrecord2.getvalue("srdata")/1048576,2)
mwerow
fl=1
else
mwbrow
mwdetail1 objrecord2.getvalue("r-host")
mwdetail1 formatnumber(objrecord2.getvalue("srdata")/1048576,2)
mwerow
fl=0
end if
'wscript.echo "uri"& objrecord2.getvalue("r-host") & "---" & objrecord2.getvalue("srdata")
objrecordset2.movenext
loop
objrecordset1.movenext
spacer(12)
loop
ofile.writeline (end_table & vbcrlf)
' write the html end to report.
ofile.writeline ("</body>")
ofile.writeline ("</html>")
ofile.close
'methods to create html(title and table) part
'=================================================================================================================
private sub mwheading(sheading)
ofile.writeline ( _
" <tr>" & vbcrlf & _
" <td colspan=7 bgcolor=#0099cc class=head>" & sheading &"</td>"& vbcrlf & _
" </tr>" & vbcrlf)
end sub
private sub mwtitle(scontent)
ofile.writeline ( _
" <td bgcolor=#0099ff align=left class=category height=14>" & scontent & "</td>" & vbcrlf)
end sub
private sub mwdetail1(scontent)
ofile.writeline ( _
" <td bgcolor=#dce3fc align=left class=result height=12>" & scontent & "</td>" & vbcrlf)
end sub
private sub mwdetail2(scontent)
ofile.writeline ( _
" <td bgcolor=#e9fbfe align=left class=result height=12>" & scontent & "</td>" & vbcrlf)
end sub
private sub mwalert1(scontent)
ofile.writeline ( _
" <td bgcolor=#dce3fc align=left class=alert height=12>" & scontent & "</td>" & vbcrlf)
end sub
private sub mwalert2(scontent)
ofile.writeline ( _
" <td bgcolor=#e9fbfe align=left class=alert height=12>" & scontent & "</td>" & vbcrlf)
end sub
private sub mwbrow
ofile.writeline ( " <tr>" & vbcrlf)
end sub
private sub mwerow
ofile.writeline ( " </tr>" & vbcrlf)
end sub
private sub spacer(iheight)
ofile.writeline ( _
" <tr><td height=" & iheight & "></td></tr>" & vbcrlf)
end sub
'=================================================================================================================
'end of create html method
'send email
dim imsg, iconf, flds
'// create the cdo connections.
set imsg = createobject("cdo.message")
set iconf = createobject("cdo.configuration")
set flds = iconf.fields
'// smtp server configuration.
with flds
.item(cdosendusingmethod) = cdosendusingport
'// set the smtp server address here.
.item(cdosmtpserver) = ssmtpserver
.update
end with
'// set the message properties.
with imsg
set .configuration = iconf
.to = smailto
.from = smailfrom
.subject = smailsub
.textbody = strmessage
end with
'imsg.htmlbody = smailmessage
'// send the message.
imsg.addattachment satt
imsg.send ' send the message.
set imsg = nothing
set iconf = nothing
上一篇: 皇甫嵩和张温早知道董卓真面目,为何最后没有除掉他?
下一篇: VBS基础编程教程 (第6篇)