荔园在线
荔园之美,在春之萌芽,在夏之绽放,在秋之收获,在冬之沉淀
[回到开始]
[上一篇][下一篇]
发信人: nicq (NoName), 信区: Homepage
标 题: asp代码精华(十二)
发信站: 荔园晨风BBS站 (Wed Apr 23 13:31:35 2003), 站内信件
遍历目录以及目录下文件的函数
<%
function bianli(path)
set fso=server.CreateObject("scripting.filesystemobject")
on error resume next
set objFolder=fso.GetFolder(path)
set objSubFolders=objFolder.Subfolders
for each objSubFolder in objSubFolders
nowpath=path + "\" + objSubFolder.name
Response.Write nowpath
set objFiles=objSubFolder.Files
for each objFile in objFiles
Response.Write "<br/>---"
Response.Write objFile.name
next
Response.Write "<p>"
bianli(nowpath)'递归
next
set objFolder=nothing
set objSubFolders=nothing
set fso=nothing
end function
%>
<%
bianli("d:") '遍历d:盘
%>
下面几个函数也许大家用的着:
public function HtmlOut(str)
'将文字转化为它的源代码格式
dim guest
if isnull(str) or str="" then
htmlOut=str
exit function
end if
guest=str
guest=Replace(Guest," "," ")
guest=Replace(Guest," ","`nbsp;")
Guest=server.htmlencode(Guest)
guest=Replace(Guest,"`nbsp;"," ")
guest=Replace(Guest,vbcrlf,"<BR>")
HtmlOut=guest
end function
public function OutOption(conn,tabel,style,value)
'从数据库中提取内容生成下拉菜单
'conn 为数据库联接 table为表名 style下接菜单样式
dim re,sql,selected
set re=server.CreateObject("ADODB.RECORDSET")
sql = "SELECT * FROM " & tabel & " ORDER BY value"
re.Open sql,conn
Response.Write ("<select " & style & ">" & vbCrLf )
while re.EOF<>true
if trim(re("value"))=trim(value) then
selected=" selected "
else
selected=" "
end if
response.write( vbTab & "<option" & selected & "value=""" &
re("value") & """>" & re("text") & "</option>" & vbCrLf )
re.MoveNext
wend
Response.Write ("</select>" & vbCrlf)
set re=nothing
end function
Public Function FormatDT(dt, style)
'style=0 2000-10-10 下午 12:17:45
'style=1 2000-10-10 23:17:45
'style=2 2000-10-10 23:45
'style=3 00-10-10 23:45
'style=4 10-10 23:45
'style=5 2000-10-10
'style=6 00-10-10
'style=7 10-10
Dim nowdate, y, m, d, h, i, s, t, APM, hAPM
nowdate = dt
y = Year(nowdate)
m = Month(nowdate)
d = Day(nowdate)
h = Hour(nowdate)
i = Minute(nowdate)
s = Second(nowdate)
If h > 12 Then
APM = "下午 "
hAPM = CStr(CInt(h) Mod 12)
Else
APM = "上午 "
hAPM = h
End If
Select Case style
Case 0
t = y & "-" & m & "-" & d & " " & APM & hAPM & ":" & i & ":" & s
Case 1
t = y & "-" & m & "-" & d & " " & h & ":" & i & ":" & s
Case 2
t = y & "-" & m & "-" & d & " " & h & ":" & i
Case 3
t = Right(y, 2) & "-" & m & "-" & d & " " & h & ":" & i
Case 4
t = m & "-" & d & " " & h & ":" & i
Case 5
t = y & "-" & m & "-" & d
Case 6
t = Right(y, 2) & "-" & m & "-" & d
Case 7
t = m & "-" & d
End Select
FormatDT = t
End Function
如何利用SQL Server来发送电子发邮件?
如何利用SQL Server发送邮件?
在SQL Server中,提供了通过Exchange或Outlook收发邮件的扩展存储过程。下面简单地介
绍一下:
一、启动SQL Mail:
xp_startmail @user,@password
其中,@user和@password都是可选的。
也可打开Enterprise Manager中的Support Services,在SQL Mail上单击右键打开右
键菜单,然后按Start来启动
二、停止SQL Mail
xp_stopmail
也可用上述方法中的菜单里的Stop来停止
三、发送邮件
xp_sendmail {[@recipients =] 'recipients [;...n]'}
[,[@message =] 'message']
[,[@query =] 'query']
[,[@attachments =] attachments]
[,[@copy_recipients =] 'copy_recipients [;...n]'
[,[@blind_copy_recipients =] 'blind_copy_recipients [;...n]'
[,[@subject =] 'subject']
[,[@type =] 'type']
[,[@attach_results =] 'attach_value']
[,[@no_output =] 'output_value']
[,[@no_header =] 'header_value']
[,[@width =] width]
[,[@separator =] 'separator']
[,[@echo_error =] 'echo_value']
[,[@set_user =] 'user']
[,[@dbuse =] 'database']
参数说明:
序号 参 数 说 明 备 注
1 @recipients 收件人。多人中间用逗号分开 必需
2 @message 要发送的信息
3 @query 确定执行并依附邮件的有效查询 除触发器中的插入表及删除表外,此
查询能引用任何对象
4 @attachments 附件
5 @copy_recipients 抄送
@blind_copy_recipients 密送
@subject 标题
@attach_results 指定查询结果做为附件发送
@no_header 不发送查询结果的列名
@set_user 查询联接的用户名 默认为Guset
@dbuse 查询所用的数据库 默认为缺省数据库
四、阅读邮件收件箱中的邮件
xp_readmail [[@msg_id =] 'message_number'] [, [@type =] 'type' [OUTPUT]]
[,[@peek =] 'peek']
[,[@suppress_attach =] 'suppress_attach']
[,[@originator =] 'sender' OUTPUT]
[,[@subject =] 'subject' OUTPUT]
[,[@message =] 'message' OUTPUT]
[,[@recipients =] 'recipients [;...n]' OUTPUT]
[,[@cc_list =] 'copy_recipients [;...n]' OUTPUT]
[,[@bcc_list =] 'blind_copy_recipients [;...n]' OUTPUT]
[,[@date_received =] 'date' OUTPUT]
[,[@unread =] 'unread_value' OUTPUT]
[,[@attachments =] 'attachments [;...n]' OUTPUT]]
[,[@skip_bytes =] bytes_to_skip OUTPUT]
[,[@msg_length =] length_in_bytes OUTPUT]
[,[@originator_address =] 'sender_address' OUTPUT]]
参数说明:
序号 参 数 说 明 备 注
1 @originator 发件人
2 @subject 主题
3 @message 信息
4 @recipients 收件人
5 @skip_tytes 读取邮件信息时跳过的字节数 用于顺序获取邮件信息段
6 @msg_length 确定所有信息的长度 通常与5一起处理长信息
五、处理下一个邮件:
xp_findnextmsg [[@msg_id =] 'message_number' [OUTPUT]]
[,[@type =] type]
[,[@unread_only =] 'unread_value']]
六、删除邮件:
xp_deletemail {'message_number'}
如果不指定邮件编号则删除收件箱中的所有邮件
七、自动处理邮件:
sp_processmail [[@subject =] 'subject']
[,[@filetype =] 'filetype']
[,[@separator =] 'separator']
[,[@set_user =] 'user']
[,[@dbuse =] 'dbname']
得到汉字拼音第一个字母的算法。可能用在查询或排序
<%
function getpychar(char)
tmp=65536+asc(char)
if(tmp>=45217 and tmp<=45252) then getpychar= "A"
if(tmp>=45253 and tmp<=45760) then getpychar= "B"
if(tmp>=47761 and tmp<=46317) then getpychar= "C"
if(tmp>=46318 and tmp<=46825) then getpychar= "D"
if(tmp>=46826 and tmp<=47009) then getpychar= "E"
if(tmp>=47010 and tmp<=47296) then getpychar= "F"
if(tmp>=47297 and tmp<=47613) then getpychar= "G"
if(tmp>=47614 and tmp<=48118) then getpychar= "H"
if(tmp>=48119 and tmp<=49061) then getpychar= "J"
if(tmp>=49062 and tmp<=49323) then getpychar= "K"
if(tmp>=49324 and tmp<=49895) then getpychar= "L"
if(tmp>=49896 and tmp<=50370) then getpychar= "M"
if(tmp>=50371 and tmp<=50613) then getpychar= "N"
if(tmp>=50614 and tmp<=50621) then getpychar= "O"
if(tmp>=50622 and tmp<=50905) then getpychar= "P"
if(tmp>=50906 and tmp<=51386) then getpychar= "Q"
if(tmp>=51387 and tmp<=51445) then getpychar= "R"
if(tmp>=51446 and tmp<=52217) then getpychar= "S"
if(tmp>=52218 and tmp<=52697) then getpychar= "T"
if(tmp>=52698 and tmp<=52979) then getpychar= "W"
if(tmp>=52980 and tmp<=53640) then getpychar= "X"
if(tmp>=53689 and tmp<=54480) then getpychar= "Y"
if(tmp>=54481 and tmp<=52289) then getpychar= "Z"
end function
function getpy(str)
for i=1 to len(str)
getpy=getpy&getpychar(mid(str,i,1))
next
end function
%>
--
(S-Term)Sorry, i'm not here
※ 来源:·荔园晨风BBS站 bbs.szu.edu.cn·[FROM: 192.168.0.180]
[回到开始]
[上一篇][下一篇]
荔园在线首页 友情链接:深圳大学 深大招生 荔园晨风BBS S-Term软件 网络书店